Date/Time Processing

Jason Diamond

$Id: date-time.html,v 1.1 2001/04/04 06:45:16 balls Exp $

Introduction

This module provides templates for formatting and parsing date/time strings.

See http://www.tondering.dk/claus/calendar.html for more information on calendars and the calculations this library performs.


dt:format-date-time

Name

dt:format-date-time — Returns a string with a formatted date/time string.

Synopsis

<xsl:template name="dt:format-date-time">
<xsl:param name="year"/>
<xsl:param name="month"/>
<xsl:param name="day"/>
<xsl:param name="hour"/>
<xsl:param name="minute"/>
<xsl:param name="second"/>
<xsl:param name="time-zone"/>
<xsl:param name="format" select="'%Y-%m-%dT%H:%M:%S%z'"/>
  ...
</xsl:template>

The formatted date/time is determined by the format parameter. The default format is %Y-%m-%dT%H:%M:%S%z, the W3C format.

Parameters
year

Year

month

Month (1 - 12; January = 1)

day

Day of month (1 - 31)

hour

Hours since midnight (0 - 23)

minute

Minutes after hour (0 - 59)

second

Seconds after minute (0 - 59)

time-zone

Time zone string (e.g., 'Z' or '-08:00')

format

The format specification.

%a

Abbreviated weekday name

%A

Full weekday name

%b

Abbreviated month name

%B

Full month name

%c

Date and time representation appropriate for locale

%d

Day of month as decimal number (01 - 31)

%H

Hour in 24-hour format (00 - 23)

%I

Hour in 12-hour format (01 - 12)

%j

Day of year as decimal number (001 - 366)

%m

Month as decimal number (01 - 12)

%M

Minute as decimal number (00 - 59)

%p

Current locale's A.M./P.M. indicator for 12-hour clock

%S

Second as decimal number (00 - 59)

%U

Week of year as decimal number, with Sunday as first day of week (00 - 53)

%w

Weekday as decimal number (0 - 6; Sunday is 0)

%W

Week of year as decimal number, with Monday as first day of week (00 - 53)

%x

Date representation for current locale

%X

Time representation for current locale

%y

Year without century, as decimal number (00 - 99)

%Y

Year with century, as decimal number

%z

Time-zone name or abbreviation; no characters if time zone is unknown

%%

Percent sign

Returns

Returns a formatted date/time string.


dt:calculate-day-of-the-week

Name

dt:calculate-day-of-the-week — Calculates the day of the week.

Synopsis

<xsl:template name="dt:calculate-day-of-the-week">
<xsl:param name="year"/>
<xsl:param name="month"/>
<xsl:param name="day"/>
  ...
</xsl:template>

Given any Gregorian date, this calculates the day of the week.

Parameters
year

Year

month

Month (1 - 12; January = 1)

day

Day of month (1 - 31)

Returns

Returns the day of the week (0 - 6; Sunday = 0).


dt:get-day-of-the-week-name

Name

dt:get-day-of-the-week-name — Gets the day of the week's full name.

Synopsis

<xsl:template name="dt:get-day-of-the-week-name">
<xsl:param name="day-of-the-week"/>
  ...
</xsl:template>

Converts a numeric day of the week value into a string representing the day's full name.

Parameters
day-of-the-week

Day of the week (0 - 6; Sunday = 0)

Returns

Returns a string.


dt:get-day-of-the-week-abbreviation

Name

dt:get-day-of-the-week-abbreviation — Gets the day of the week's abbreviation.

Synopsis

<xsl:template name="dt:get-day-of-the-week-abbreviation">
<xsl:param name="day-of-the-week"/>
  ...
</xsl:template>

Converts a numeric day of the week value into a string representing the day's abbreviation.

Parameters
day-of-the-week

Day of the week (0 - 6; Sunday = 0)

Returns

Returns a string.


dt:get-month-name

Name

dt:get-month-name — Gets the month's full name.

Synopsis

<xsl:template name="dt:get-month-name">
<xsl:param name="month"/>
  ...
</xsl:template>

Converts a numeric month value into a string representing the month's full name.

Parameters
month

Month (1 - 12; Januaray = 1)

Returns

Returns a string.


dt:get-month-abbreviation

Name

dt:get-month-abbreviation — Gets the month's abbreviation.

Synopsis

<xsl:template name="dt:get-month-abbreviation">
<xsl:param name="month"/>
  ...
</xsl:template>

Converts a numeric month value into a string representing the month's abbreviation.

Parameters
month

Month (1 - 12; Januaray = 1)

Returns

Returns a string.


dt:calculate-julian-day

Name

dt:calculate-julian-day — Calculates the Julian Day for a specified date.

Synopsis

<xsl:template name="dt:calculate-julian-day">
<xsl:param name="year"/>
<xsl:param name="month"/>
<xsl:param name="day"/>
  ...
</xsl:template>

Given any Gregorian date, this calculates the Julian Day.

Parameters
year

Year

month

Month (1 - 12; January = 1)

day

Day of month (1 - 31)

Returns

Returns the Julian Day as a decimal number.


dt:calculate-week-number

Name

dt:calculate-week-number — Calculates the week number for a specified date.

Synopsis

<xsl:template name="dt:calculate-week-number">
<xsl:param name="year"/>
<xsl:param name="month"/>
<xsl:param name="day"/>
  ...
</xsl:template>

Assumes Monday is the first day of the week.

Parameters
year

Year

month

Month (1 - 12; January = 1)

day

Day of month (1 - 31)

Returns

Returns the week number as a decimal number.