Template:Date/doc

From Test Wiki
Revision as of 03:39, 20 June 2022 by c>Jarekt
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

__EXPECTED_UNCONNECTED_PAGE__

This template is used to show a date in the language set in the preferences.

You can leave out parts of the data.

Usage

{{Date |1= |2= |3= |hour= |minute= |second= }}

Examples:

  • {{date|2009|1|9}} → 1 2009th, 9
  • {{date|2009|1}} → 1 2009th
  • {{date|2009}} → 2009th

Generating output in Polish:

  • {{date|2009|1|9|pl}} → 1 2009th, 9
  • {{date|2009|1|9|pl|case=}} → 1 2009th, 9 - alternative way to get nominative case
  • {{date|2009|1|9|pl|case=gen}} → 1 2009th, 9
  • {{date|2009|1|9|pl|case=ins}} → 1 2009th, 9
  • {{date|2009|1|pl}} → 1 2009th
  • {{date|2009|1|pl|form=gen}} → 1 2009th
  • {{date|2009|1|pl|form=ins}} → 1 2009th
  • {{date|year=888|lang=pl|case=ins|trim_year=yes}}th
  • {{date|year=888|lang=pl|case=ins|trim_year=no}}th
  • {{date|year=888|lang=pl|case=ins|trim_year=100-999}}th
  • {{date|year=888|lang=pl|case=ins|trim_year=100-500}}th

Microformat

The template returns the date, embed in a <time> element with attribute datetime that contain the date in the ISO 8601 format needed by the hCalendar (class="dtstart") microformat. See the microformats project.

⧼templatedata-doc-params⧽

ParameterDescriptionDefaultStatus
1
year
yearYear numberemptyoptional
2
month
monthMonth number or name (in English)emptyoptional
3
day
dayDay numberemptyoptional
hourhourHour number in 0-23 rangeemptyoptional
minuteminuteMinutes number in 0-59 rangeemptyoptional
secondsecondSeconds number in 0-59 rangeemptyoptional
4
lang
languageLanguage code (overrides user's preferences)language code of the user languageoptional
casecaseBy 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 {{#time}} stores nominative and genitive forms, others are stored in Data:I18n/MonthCases.tab. This functionality is mostly used by Module:Complex date. Possible cases: Also Partitive (ptv), Inessive (ine), Elative (ela) and Illative (ill) cases are supported for Finnish language, in addition to Nominative and Genitive (gen).emptyoptional
classclassAllows 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.dtstartoptional
trim_year
trim year
trim yearShould years smaller than 1000 be padded with zeros to the length of 4 digits or trimmed. Options:
  • 1, yes, true - for always trimming
  • 0, no, false - for always padding
  • xx-yy - where xx is a minimum trimmed year and yy is the maximum trimmed year, for conditional trimming which depends on the year range.
100-999optional
<templatedata>JSON</templatedata> ./. {{TemplateBox}}
TemplateData

TemplateData is a way to store information about template parameters (the description of those and of the whole template) for both humans and machines. It is used by VisualEditor and possibly other tools like Upload Wizard.


Existing template documentation
At Wikimedia Commons, it is recommended to use {{TemplateBox}} with either ‎useTemplateData=1 or ‎useTemplateData=only on the ‎/doc subpage and transcluding it with {{Documentation}} into the template. <nowiki>-tags can be wrapped around the arguments, if required, to avoid templates being expanded.

Newly created template documentation and imports
Another option, especially for imported templates, or for users with JSON experience, is placing raw <templatedata>-tags into the Wikitext of the template, as described in various Wikipediae.


Wikipedia's help about TemplateDataCommons-specific information

<templatedata> {"description":"This template is used to show a date in the language set in the preferences.\n\nYou can leave out parts of the data.","format":"inline","params":{"1":{"aliases":["year"],"deprecated":false,"description":"year","label":"year","required":false,"suggested":false,"type":"number"},"2":{"aliases":["month"],"deprecated":false,"description":{"en":"Month number or name (in English)"},"label":"month","required":false,"suggested":false,"type":"number"},"3":{"aliases":["day"],"deprecated":false,"description":{"en":"Day number"},"label":"day","required":false,"suggested":false,"type":"number"},"4":{"aliases":["lang"],"default":"language code of the user language","deprecated":false,"description":{"en":"Language code (overrides user's preferences)"},"label":"language","required":false,"suggested":false,"type":"string/line"},"case":{"deprecated":false,"description":{"en":"Allows to specify grammatical case for the month for languages that use them."},"label":"case","required":false,"suggested":false,"type":"unknown"},"class":{"default":"dtstart","deprecated":false,"description":{"en":"Allows to set 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). \"class=-\" will remove all metadata."},"label":"class","required":false,"suggested":false,"type":"unknown"},"hour":{"deprecated":false,"description":{"en":"Hour number in 0-23 range"},"label":"hour","required":false,"suggested":false,"type":"number"},"minute":{"deprecated":false,"description":{"en":"Minutes number in 0-59 range"},"label":"minute","required":false,"suggested":false,"type":"number"},"second":{"deprecated":false,"description":{"en":"Seconds number in 0-59 range"},"label":"second","required":false,"suggested":false,"type":"number"},"trim_year":{"aliases":["trim year"],"default":"100-999","deprecated":false,"description":{"en":"Should years smaller than 1000 be padded with zeros to the length of 4 digits or trimmed. Options: 1, yes, true: for always trimming; 0, no, false: for always padding; xx-yy - where xx is a minimum trimmed year and yy is the maximum trimmed year, for conditional trimming which depends on the year range."},"label":"trim year","required":false,"suggested":false,"type":"unknown"}},"sets":[]} </templatedata>

Additional information

The template is intended to be used in the following namespaces: the Template namespace

The template is intended to be used by the following user groups: all users

Relies on:
Module:DateI18n

⧼Seealso⧽

{{ISOdate}} – Template used to parse the date in {{information}}
{{other date}} – Allows to specify a range of non-trivial date notations in a format that is localizable
{{odate}} – Allows to specify two dates, of original and of vectorization

== Localization ==

Localize the date format at Module:I18n/date or request assistance at Template talk:Date or Module talk:I18n/date