Diskordische Datumsangaben und Feiertage für den Kalender
git-svn-id: svn://svn.c3d2.de/c3d2-web/trunk@582 31f61c52-7bfb-0310-b897-fc00f8a278f0
This commit is contained in:
parent
67f0c99ef8
commit
a1a3410a2b
|
@ -0,0 +1,26 @@
|
|||
require 'xml/xslt'
|
||||
|
||||
$xslt = XML::XSLT.new
|
||||
$xslt.xsl = File::dirname($0) + '/../xsl/ddate.xsl'
|
||||
|
||||
def call_xslt(date)
|
||||
$xslt.xml = "<ddate-test xmlns='http://www.c3d2.de/ddate-test'>#{date.strftime('%Y-%m-%d')}</ddate-test>"
|
||||
result = $xslt.serve
|
||||
result.sub!(/^<\?.+?>/, '')
|
||||
result.strip
|
||||
end
|
||||
|
||||
def call_prog(date)
|
||||
`ddate '+%A, the %e of %B, %Y - %H' #{date.strftime('%d %m %Y')}`.strip
|
||||
end
|
||||
|
||||
day = Time.now
|
||||
loop do
|
||||
puts day.strftime('%Y-%m-%d')
|
||||
xslt = call_xslt(day)
|
||||
prog = call_prog(day)
|
||||
if prog != xslt
|
||||
p('xslt' => xslt, 'prog' => prog)
|
||||
end
|
||||
day += 24 * 60 * 60
|
||||
end
|
|
@ -6,6 +6,7 @@
|
|||
exclude-result-prefixes="xsl date">
|
||||
|
||||
|
||||
<xsl:include href="ddate.xsl" />
|
||||
|
||||
<xsl:template match="/page/calendar-summary">
|
||||
<table border="0" class="calendar">
|
||||
|
@ -70,9 +71,16 @@
|
|||
<xsl:otherwise>3</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
<span class="day">
|
||||
|
||||
<xsl:variable name="ddate">
|
||||
<xsl:call-template name="ddate">
|
||||
<xsl:with-param name="date" select="$date"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<span class="day" title="{$ddate}">
|
||||
<xsl:value-of select="date:day-in-month($date)"/>
|
||||
</span>
|
||||
|
||||
<ul>
|
||||
<xsl:for-each select="event">
|
||||
<xsl:sort select="start"/>
|
||||
|
@ -101,6 +109,16 @@
|
|||
</li>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
|
||||
<xsl:variable name="dholiday">
|
||||
<xsl:call-template name="ddate-holiday">
|
||||
<xsl:with-param name="date" select="$date"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:if test="string-length(normalize-space($dholiday)) > 0">
|
||||
<li><xsl:value-of select="normalize-space($dholiday)"/></li>
|
||||
</xsl:if>
|
||||
</ul>
|
||||
</td>
|
||||
<xsl:if test="date:day-in-week($date) != 1"> <!-- Sunday? Break and return to output-week... -->
|
||||
|
|
|
@ -0,0 +1,138 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This code is distributed under the GPLv2 OR LATER -->
|
||||
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:date="http://exslt.org/dates-and-times">
|
||||
|
||||
<xsl:template name="ddate">
|
||||
<xsl:param name="date"/>
|
||||
|
||||
<xsl:variable name="yday" select="date:day-in-year($date)"/>
|
||||
<xsl:variable name="season" select="floor(($yday - 1) div 73) + 1"/>
|
||||
<xsl:variable name="mday" select="(($yday - 1) mod 73) + 1"/>
|
||||
<xsl:variable name="wday" select="($yday - 1) mod 5"/>
|
||||
|
||||
<!--discordian-date>
|
||||
<season><xsl:value-of select="$season"/></season>
|
||||
<day><xsl:value-of select="$mday"/></day>
|
||||
<wday><xsl:value-of select="$wday"/></wday>
|
||||
<yday><xsl:value-of select="$yday"/></yday>
|
||||
<year><xsl:value-of select="date:year($date) + 1166"/></year>
|
||||
|
||||
<season-long>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$season = 1">Chaos</xsl:when>
|
||||
<xsl:when test="$season = 2">Discord</xsl:when>
|
||||
<xsl:when test="$season = 3">Confusion</xsl:when>
|
||||
<xsl:when test="$season = 4">Bureaucracy</xsl:when>
|
||||
<xsl:when test="$season = 5">The Aftermath</xsl:when>
|
||||
<xsl:otherwise>???</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</season-long>
|
||||
<season-short>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$season = 1">Chs</xsl:when>
|
||||
<xsl:when test="$season = 2">Dsc</xsl:when>
|
||||
<xsl:when test="$season = 3">Cfn</xsl:when>
|
||||
<xsl:when test="$season = 4">Bcy</xsl:when>
|
||||
<xsl:when test="$season = 5">Afm</xsl:when>
|
||||
<xsl:otherwise>?</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</season-short>
|
||||
|
||||
<day-long>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$wday = 0">Sweetmorn</xsl:when>
|
||||
<xsl:when test="$wday = 1">Boomtime</xsl:when>
|
||||
<xsl:when test="$wday = 2">Pungenday</xsl:when>
|
||||
<xsl:when test="$wday = 3">Prickle-Prickle</xsl:when>
|
||||
<xsl:when test="$wday = 4">Setting Orange</xsl:when>
|
||||
<xsl:otherwise>???</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</day-long>
|
||||
<day-short>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$wday = 0">SM</xsl:when>
|
||||
<xsl:when test="$wday = 1">BT</xsl:when>
|
||||
<xsl:when test="$wday = 2">PD</xsl:when>
|
||||
<xsl:when test="$wday = 3">PP</xsl:when>
|
||||
<xsl:when test="$wday = 4">SO</xsl:when>
|
||||
<xsl:otherwise>?</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</day-short>
|
||||
</discordian-date-->
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$wday = 0">Sweetmorn</xsl:when>
|
||||
<xsl:when test="$wday = 1">Boomtime</xsl:when>
|
||||
<xsl:when test="$wday = 2">Pungenday</xsl:when>
|
||||
<xsl:when test="$wday = 3">Prickle-Prickle</xsl:when>
|
||||
<xsl:when test="$wday = 4">Setting Orange</xsl:when>
|
||||
<xsl:otherwise>???</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>, the </xsl:text>
|
||||
<xsl:value-of select="$mday"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$mday mod 10 = 1">st</xsl:when>
|
||||
<xsl:when test="$mday mod 10 = 2">nd</xsl:when>
|
||||
<xsl:when test="$mday mod 10 = 3">rd</xsl:when>
|
||||
<xsl:otherwise>th</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text> of </xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$season = 1">Chaos</xsl:when>
|
||||
<xsl:when test="$season = 2">Discord</xsl:when>
|
||||
<xsl:when test="$season = 3">Confusion</xsl:when>
|
||||
<xsl:when test="$season = 4">Bureaucracy</xsl:when>
|
||||
<xsl:when test="$season = 5">The Aftermath</xsl:when>
|
||||
<xsl:otherwise>???</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>, </xsl:text>
|
||||
<xsl:value-of select="date:year($date) + 1166"/>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="ddate-holiday">
|
||||
<xsl:param name="date"/>
|
||||
|
||||
<xsl:variable name="yday" select="date:day-in-year($date)"/>
|
||||
<xsl:variable name="mday" select="(($yday - 1) mod 73) + 1"/>
|
||||
<xsl:variable name="season" select="floor(($yday - 1) div 73) + 1"/>
|
||||
|
||||
<xsl:choose>
|
||||
<!-- APOSTLE HOLIDAYS -->
|
||||
<xsl:when test="$mday = 5">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$season = 1">Mungday</xsl:when>
|
||||
<xsl:when test="$season = 2">Mojoday</xsl:when>
|
||||
<xsl:when test="$season = 3">Syaday</xsl:when>
|
||||
<xsl:when test="$season = 4">Zaraday</xsl:when>
|
||||
<xsl:when test="$season = 5">Maladay</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<!-- SEASON HOLIDAYS -->
|
||||
<xsl:when test="$mday = 50">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$season = 1">Chaoflux</xsl:when>
|
||||
<xsl:when test="$season = 2">Discoflux</xsl:when>
|
||||
<xsl:when test="$season = 3">Confuflux</xsl:when>
|
||||
<xsl:when test="$season = 4">Bureflux</xsl:when>
|
||||
<xsl:when test="$season = 5">Afflux</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Test support code -->
|
||||
<xsl:template match="dt:ddate-test" xmlns:dt="http://www.c3d2.de/ddate-test">
|
||||
<xsl:call-template name="ddate">
|
||||
<xsl:with-param name="date" select="."/>
|
||||
</xsl:call-template>
|
||||
<xsl:text> - </xsl:text>
|
||||
<xsl:call-template name="ddate-holiday">
|
||||
<xsl:with-param name="date" select="."/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
Loading…
Reference in New Issue