XML technologies / XSLT / XSLT Kochbuch / Dates and times / Working with the Julian calendar
(Excerpt from "XSLT Kochbuch" by Sal Mangano)
Problem
You need to work with the old Julian calendar system.
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 the other recipes in this chapter to format dates, perform date calculations or convert dates to other calendar systems.
Discussion
The Julian system is rarely used in modern times. (The Russian Orthodox Church is an exception.) The Julian calendar was abandoned in favor of the Gregorian calendar because it estimates the length of a year at 365 1/4 days, which is somewhat inaccurate. The mean length is actually 365.2425 days. Over time, the Julian system caused the seasons to drift.
Copyright © 2006 O'Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from "XSLT Kochbuch" is subject to the same terms as the printed edition: the work and all its parts are protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O'Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de