Formatting of dates is achieved using the functions fn:format-date(), fn:format-time(), and fn:format-dateTime(). The third argument of these functions supplies the requested language; the fifth argument supplies the requested "place". If not supplied, the defaults are taken from the Saxon configuration (properties DEFAULT_LANGUAGE and DEFAULT_COUNTRY; if these are not set, they fall back to values obtained from operating system settings.
Where parts of a date are formatted as numbers (for example "1st December") the rules closely follow the rules for formatting of numbers. This includes spellout numbering (for example "December First, Two Thousand and Twenty-One").
Month names and day names (e.g. "January", "Friday") are handled as follows:
- In SaxonJ, the full English month names and day names are hard-coded in the product. Month names are abbreviated to the required length by truncation; for day names, there are custom rules for abbreviation ("Weds" is preferred to "Wedn", and names are never shortened to the point where they become ambiguous, thus "Tu" and "Th" for "Tuesday" and "Thursday").
- In SaxonJ-HE, month and day names for languages other than English are not available unless a localization plug-in is registered using the Configuration.setLocalizerFactory() mechanism
- In SaxonJ-PE and -EE, month and day names are obtained using the ICU4J library. If the full name delivered by ICU exceeds the requested maximum lengh, the short name is requested from ICU.
- In SaxonCS, month and day names are obtained using the .NET
CultureInfoclass. If the full name (for example
CultureInfo.DateTimeFormat.GetMonthName(m)) exceeds the requested maximum length, then the abbreviated form is used (
DateTimeFormat.GetAbbreviatedMonthName(m)). If necessary the result is space-padded on the right to the requested minimum width.
Formatting of timezones is complex. Named timezones (such as EST, PDT) are used only if the
place argument represents the US or UK, and only if the timezone is one of a number of
abbreviations that are commonly recognized in those countries. The rules take into account whether the
date is in daylight savings (summer) time.
For more details on writing a plug-in for localizing numbers and dates, see Localizing numbers and dates.