Chapter 4. Dates and Times
Does anyone really know what time it is? Does anyone really care?
Chicago
Introduction
Native XSLT 1.0 does not know what time it is and does not seem to care. However, dates and times are a necessary aspect of everyday life. The need to manipulate them arises frequently in computing, especially in web development. Therefore, it was surprising and unfortunate that standard XSLT 1.0 did not have any built-in date and time support.
The situation in XSLT 2.0 has improved substantially. XPath 2.0 has
numerous functions for manipulating dates, times, and durations. In
fact, the only thing 2.0 leaves us wanting for, with respect to date
and time, is functions with shorter names! I am told names like
subtract-dates-yielding-yearMonthDuration() were
provided partly to appease the XQuery database weenies. The
alternation between dashes and camelcase follows from the differing
conventions adopted by XPath and XML Schema committees.
The examples in this section can help compensate for XSLT 1.0’s lack of support for dates and times. Unfortunately, one of the most crucial date and time capabilities cannot be implemented in XSLT 1.0—that is, getting the current date and time. For that, you need to call out to another language whose library supports interacting with the hardware’s real-time clock. Both Java and JavaScript have this capability. If your application just needs to format dates and times that already exist in a document, then the routines here should cover ...