Name

f:date-format — Returns the format string for a date.

Function:
{http://docbook.org/ns/docbook/functions}date-format#1
Defined in:
modules/functions.xsl
Used in:
modules/inlines.xsl

Synopsis

f:date-format($context as element()) as xs:string

Description

Dates may be stored in a variety of formats and the pubdate element even allows inline markup. The f:date-format() function determines how a date will be formatted:

  • If the date contains embedded markup, the special value “apply-templates” is returned to indicate that string formatting isn’t appropriate.

  • If the date conforms to an ISO 8601 date, the $date-date-format string is returned.

  • If the date conforms to an ISO 8601 dateTime, the $date-dateTime-format string is returned.

  • If the date does not conform to either of those date formats, “apply-templates” is returned.

If the date conforms to a date or dateTime, the author may override the format string by providing a db processing instruction with a date-format pseudo-attribute.

Example 1.1, Several dates in ISO 8601 formats shows an example of several dates that may be formatted in more familiar forms.

 
<para>The Unix epoch begins at
<date>1970-01-01T00:00:00Z</date>.
Grace Hopper was born on <date>1906-12-09</date>.
That was a <date><?db date-format="[F]"?>1906-12-09</date>.
I was born on a <date>Friday</date>.</para>
Example 1.1 Several dates in ISO 8601 formats

With default formats, these are formatted as shown:

The Unix epoch begins at 00:00 01 Jan 1970. Grace Hopper was born on 09 Dec 1906. That was a Sunday. I was born on a Friday.