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 on Wikimedia Commons and it is being used by several other modules like Module:ISOdate or Module:Complex date.

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 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
 * {| class="wikitable"

! Format string !! Meaning !! Comments
 * + Date formats
 * YMDHMS || YYYY:MM:DD, HH:MM:SS format for year, month, day, hour, minutes, seconds || Most items in the list use format created from YMD format with hour, minutes and seconds added with ", HH:MM:SS". All languages using this format do not have to be listed, as they default to English.
 * YMDHM || YYYY:MM:DD, HH:MM format for year, month, day, hour, minutest || Most items in the list use format created from YMD format with hour and minutes added with ", HH:MM". All languages using this format do not have to be listed, as they default to English.
 * YMD   || YYYY:MM:DD format for year, month, day || The languages using the same format as English do not need to be listed.
 * YM    || YYYY:MM (year-month) format  for year and month ||The languages using the same format as English do not need to be listed.
 * MD    || MM:DD (month-day) format for month and day ||The languages using the same format as English do not need to be listed.
 * Y     || YYYY (year only) format for year || Most languages show year as a simple number, those do not have to be listed as they will default to English.
 * M     || month name only || Most languages show year as a simple number, those do not have to be listed as they will default to English.
 * }
 * MD    || MM:DD (month-day) format for month and day ||The languages using the same format as English do not need to be listed.
 * Y     || YYYY (year only) format for year || Most languages show year as a simple number, those do not have to be listed as they will default to English.
 * M     || month name only || Most languages show year as a simple number, those do not have to be listed as they will default to English.
 * }
 * M     || month name only || Most languages show year as a simple number, those do not have to be listed as they will default to English.
 * }
 * }

Some languages like French Catalan, Gallic or Basque use different form for year-month-day dates depending on the day of the month. the format of the Tabular Data allowed only simple strings to be stored in multi-language arrays. In order to overcome that we stored data in strings that might look like. This string is converted to following json code by replacing ”-double-quotes with regular straight double-quotes than parsed and converted into Lua dictionary table. We convert day from the date into a key by adding "d" to a 2-digit integer representing day. If that key is in the dictionary than that form will be used otherwise we will use default form. The final step before passing it to parser function we will replace single quotes with double quotes which have special meaning for that function.
 * Special cases

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