Recipe 4.6. Working with the Julian Calendar
Problem
You
need to work in the old Julian system of dates.
Solution
<xsl:template name="ckbk:julian-date-to-julian-day">
<xsl:param name="year"/>
<xsl:param name="month"/>
<xsl:param name="day"/>
<xsl:variable name="a" select="floor((14 - $month) div 12)"/>
<xsl:variable name="y" select="$year + 4800 - $a"/>
<xsl:variable name="m" select="$month + 12 * $a - 3"/>
<xsl:value-of
select="$day + floor((153 * $m + 2) div 5) + 365 * $y
+ floor($y div 4) - 32083"/>
</xsl:template>
Once you have the Julian day, you can use other recipes in this
chapter for date formatting, date math, or conversion to other
calendar systems.
Discussion
The Julian system is rarely used in modern times. (One exception is
the Russian Orthodox Church.) The Julian calendar was abandoned in
favor of the Gregorian calendar due to its slightly inaccurate
estimate of a year containing 365 1/4 days. The mean length is
actually 365.2425 days, and over time, the seasons began to shift
under the Julian system.
 |