Module:DateI18n/doc

Summary
This module is intended for creating of date strings in any language. It serves as a back-end of Date template. See documentation of that template for documentation.

The internationalization of the date formats can be found at c:Data:DateI18n.tab and c:Data:I18n/MonthCases.tab. Module:DateI18n is called from Module:ISOdate.

Date
This module should only be called from Date template. Please call that template to access this module. Also see Date template for full documentation

Usage:

Parameters:
 * year, month, day, hour, minute, second
 * (most are optional) parameters specifying part of the date


 * tzhour, tzmin
 * (optional and rarely used) time zone offset from UTC


 * lang
 * (optional) language to be used to display the date. If not specified language of the user will be used


 * class
 * (optional) Allows setting of the HTML class of the time node where the date is included. This is useful for microformats. The default value is, for legacy reasons, "dtstart" (used by hCalendar). See the microformats project. "class=" will remove all metadata.


 * case
 * (optional) By default each language uses preferred form of the date, which typically has month in nominative or genitive grammatical case. With case parameter one can overwrite the preferred case with some other one used by a given language. Parser function stores nominative and genitive forms, others are stored in c:Data:I18n/MonthCases.tab. This functionality is mostly used by Module:Complex date.


 * trim_year
 * trim_year parameter

Example:
 * produces

Using this module from Lua code
In order to use the functions in this module from another Lua module you first have to import this module. Example:

_Date
Usage:

I18n tables
This module stores all the language specific settings in two files in "Data" namespace: Data:DateI18n.tab and Data:I18n/MonthCases.tab

Data:DateI18n.tab
Translation table with different forms of dates. Outputs are in the format used by parser function. There are several date formats supported, which depend on the data provided

For marking litteral text (notably with Basic Latin letters) that must be ouput as is (and not recognized as possible placeholders for formatting individual date fields values), you may use straight ASCII single quotes within all specified formats (instead of the straight ASCII double quotes, normally required for litteral text in forms given to the  parser function).

If a specified format needs to embed an apostrophe to be returned litterally (and not to be recognized as the alternative delimiter now reserved for marking litterals for ), the curly apostrophe-quote character U+2019 (’) must be used instead, or any other apostrophe-like character suitable for the target language: the ASCII single quote is ambiguous in all languages (and can also cause problems with Mediawiki syntax for marking bold/italic styles surrounding the generated date) and there are other preferred characters.

Note that formats 'YMDHMS' and 'YMDHM' are legacy aliases present in Data:DateI18n.tab. They have two 'M' in them: the first 'M' means month, the second 'M' means minute only after the 'H' meaning hour. These aliases have been kept in the tabular data, for compatiblity with some other modules that would expect these two legacy keys. For adding more formats showing time with fields for hour, minute and second, distinctive lower case letters 'hms' should be used.


 * {|class="wikitable"

!scope="col"| Format string !scope="col"| Meaning !scope="col"| Comments year, month name, day of the month, hour, minute, and second All languages using this format do not have to be listed, as they default to this simple rule used in English. year, month name, day of the month, hour, and minute All languages using this format do not have to be listed, as they default to to this simple rule used in English. year, month name, and day of the month year and month name All languages using this format do not have to be listed, as they default to to this simple rule used in English. the year only month name, day of the month, hour, minute, and second All languages using this format do not have to be listed, as they default to this simple rule used in English. month name, day of the month, hour, and minute All languages using this format do not have to be listed, as they default to this simple rule used in English. month name and day of the month Some language prefer placing the day of the month after the month name. Some languages need to use a genitive form for the month name, or will use different forms for specific days of the month All languages using this format do not have to be listed, as they default to this simple rule used in English. the month name only
 * + Date formats
 * YMDhms or YMDHMS || "YYYY-MM-DD, hh:mm:ss" format for:
 * YMDhms or YMDHMS || "YYYY-MM-DD, hh:mm:ss" format for:
 * Most items in the list use format created from the YMD format, with hour, minutes and seconds added with ", HH:MM:SS".
 * YMDhm or YMDHM || "YYYY-MM-DD, hh:mm" format for:
 * YMDhm or YMDHM || "YYYY-MM-DD, hh:mm" format for:
 * Most items in the list use format created from the YMD format, with hour and minutes added with ", HH:MM".
 * YMD || "YYYY-MM-DD" format for:
 * YMD || "YYYY-MM-DD" format for:
 * Languages using the same format as English do not need to be listed.
 * YM || "YYYY-MM" format for:
 * YM || "YYYY-MM" format for:
 * Most items in the list use the format created from the M format, with the year added with " YYYY" and created from the Y format.
 * Y || "YYYY" format for:
 * Y || "YYYY" format for:
 * Most languages show year as a simple number, those do not have to be listed as they will default to the same format as English.
 * MDhms || "MM-DD, hh:mm:ss" format for:
 * MDhms || "MM-DD, hh:mm:ss" format for:
 * Most items in the list use the format created from the MD format, with hour, minutes and seconds added with ", HH:MM:SS".
 * MDhm || "MM-DD, hh:mm" format for:
 * MDhm || "MM-DD, hh:mm" format for:
 * Most items in the list use the format created from the MD format, with hour, minutes and seconds added with ", HH:MM".
 * MD || "MM-DD" format for:
 * MD || "MM-DD" format for:
 * Most items in the list use the format created from the M format, with the day number prepended with "DD ".
 * M || "MM" format for:
 * M || "MM" format for:
 * Languages may have multiple forms to be listed for specific months, depending on their grammatical case of use.
 * }

Some languages like Catalan, Basque, French, or Irish use different forms for dates, depending on the day of the month.
 * Special cases

The format of the Tabular Data (and its eiting interface) allowed only simple strings to be stored in multi-language arrays, not JSON subtables. So the following is still not accepted in Tabular data pages on this wiki, even though it is a valid JSON syntax: [  ...    "en": "j' 'F' 'Y", ...   "fr" : { "default": "j' 'F' 'Y", "d01": ‟j'er 'F' 'Y" },    ... ]

In order to overcome that, we stored the JSON subtable inside translation strings (already surrounded by ASCII double quotes required by JSON for the main tabular data) by using curly quotes instead of ASCII quotes for strings in the embedded JSON table; that might look like:

This string is converted by replacing curly double quotes, any one in U+201C..U+201F (“”„‟), found in tabular data with regular ASCII straight double-quotes as:

which is then parsable as valid JSON and converted into a Lua dictionary table.

Using curly double quotes is supported only in string values embedding JSON data (i.e. a table delimited by braces "{}" inside the string) containing at least the field named ‟default”. For all other formats (using simple strings), you must use ASCII double quotes to delimit them, and curly double quotes will be recognized as part of the litteral text in the ouput.

Then the field value representing the day of the month of the given date is converted into a key by prepending ‟d” to the 2-digit integer for that day. If this key is found in the parsed dictionary, then the form specified by the value associated to that key will be used, otherwise we will use the form specified by the value associated to the ‟default” key.

An alternative (as long as Tabular data only allows simple strings in translations) using normal JSON syntax within values would have required escaping with a prepended backslash each one of these embedded double quotes (which would be less readable and more errorprone to edit with the current user interface for tabular data on this wiki):

In all cases, you must use ASCII single quotes (instead of ASCII double quotes) for marking litteral text to display as is, and you must use curly apostrophes (inside or outside marked litterals) for any apostrophe to display as is.

Data:I18n/MonthCases.tab
Grammatical cases of month names in different languages used by Module:DateI18n and Module:Complex_date.