Template:Date/doc: Difference between revisions
More actions
No edit summary |
add TemplateData documentation |
||
| Line 2: | Line 2: | ||
{{TemplateBox | {{TemplateBox | ||
|1 = year | |1 = 1 | ||
| | |1aliases=year | ||
|1label = year | |||
|1d-en = Year number | |1d-en = Year number | ||
|1d-td = year | |1d-td = year | ||
|1type = number | |1type = number | ||
|1stat = optional | |1stat = optional | ||
|2 = month | |2 = 2 | ||
| | |2aliases=month | ||
|2label = month | |||
|2d-en = Month number or name (in English) | |2d-en = Month number or name (in English) | ||
|2type = number | |2type = number | ||
|2stat = optional | |2stat = optional | ||
|3 = day | |3 = 3 | ||
| | |3aliases=day | ||
|3label = day | |||
|3d-en = Day number | |3d-en = Day number | ||
|3type = number | |3type = number | ||
|3stat = optional | |3stat = optional | ||
|4 = hour | |4 = hour | ||
|4label = hour | |||
|4d-en = Hour number in 0-23 range | |4d-en = Hour number in 0-23 range | ||
|4type = number | |4type = number | ||
|4stat = optional | |4stat = optional | ||
|5 = minute | |5 = minute | ||
|5label = minute | |||
|5d-en = Minutes number in 0-59 range | |5d-en = Minutes number in 0-59 range | ||
|5type = number | |5type = number | ||
|5stat = optional | |5stat = optional | ||
|6 = second | |6 = second | ||
|6label = second | |||
|6d-en = Seconds number in 0-59 range | |6d-en = Seconds number in 0-59 range | ||
|6type = number | |6type = number | ||
|6stat = optional | |6stat = optional | ||
|14 = lang | |14 = 4 | ||
| | |14aliases=lang | ||
|14label = language | |||
|14d-en = Language code (overrides user's preferences) | |14d-en = Language code (overrides user's preferences) | ||
|14type = string/line | |||
|14type = string | |||
|14def = language code of the user language | |14def = language code of the user language | ||
|14stat = optional- | |14stat = optional- | ||
| Line 58: | Line 52: | ||
|15=case | |15=case | ||
|15alias=form | |15alias=form | ||
|15d-en= | |15label = case | ||
|15d-en=Allows to specify [[:en:Grammatical case|grammatical case]] for the month for languages that use them. Possible cases: | |||
*leave blank for default case, which is usually [[:en:Nominative case|nominative]] or [[:en:Genitive case|genitive case]] | *leave blank for default case, which is usually [[:en:Nominative case|nominative]] or [[:en:Genitive case|genitive case]] | ||
*"case=nom" for [[:en:Nominative case|nominative case]] | *"case=nom" for [[:en:Nominative case|nominative case]] | ||
| Line 65: | Line 60: | ||
*"case=ins" for [[:en:Instrumental case|instrumental case]] (supported for ru, pl, cs, sk & sl languages) | *"case=ins" for [[:en:Instrumental case|instrumental case]] (supported for ru, pl, cs, sk & sl languages) | ||
Also [[:en:Partitive case|Partitive]] (ptv), [[:en:Inessive case|Inessive]] (ine), [[:en:Elative case|Elative]] (ela) and [[:en:Illative case|Illative]] (ill) cases are supported for Finnish language, in addition to [[:en:Nominative case|Nominative]] and [[:en:Genitive case|Genitive]] (gen). | Also [[:en:Partitive case|Partitive]] (ptv), [[:en:Inessive case|Inessive]] (ine), [[:en:Elative case|Elative]] (ela) and [[:en:Illative case|Illative]] (ill) cases are supported for Finnish language, in addition to [[:en:Nominative case|Nominative]] and [[:en:Genitive case|Genitive]] (gen). | ||
|15d-td-en= Allows to specify grammatical case for the month for languages that use them. | |||
|15d-td | |||
|15stat = optional- | |15stat = optional- | ||
|16=class | |16=class | ||
|16label = class | |16label = class | ||
|16d-td | |16d-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 [[w:HCalendar|hCalendar]]). See [[Commons:Microformats Project|the microformats project]]. "class=" will remove all metadata. | ||
|16d-td-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). Empty value will remove all metadata. | |||
|16def = dtstart | |16def = dtstart | ||
|16stat = optional- | |16stat = optional- | ||
| Line 78: | Line 72: | ||
|17=trim_year | |17=trim_year | ||
|17aliases= trim year | |17aliases= trim year | ||
|17d-en=Should years smaller than 1000 be padded with zeros to the length of 4 digits or trimmed. Options: | |17label = trim year | ||
|17d-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 | *1, yes, true - for always trimming | ||
*0, no, false - for always padding | *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. | *''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. | ||
|17d-td-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. | |||
|17d-td | |||
|17def = 100-999 | |17def = 100-999 | ||
|17stat = optional- | |17stat = optional- | ||
| Line 119: | Line 113: | ||
|shorthand= | |shorthand= | ||
|relieson=[[Module:Date]] | |relieson=[[Module:Date]] | ||
}} | |useTemplateData = 1 | ||
}}<includeonly> | |||
<includeonly> | [[Category:Time, date and calendar templates]] | ||
[[Category:Time, date and calendar templates | [[Category:User interface language dependent templates]] | ||
[[Category:User interface language dependent templates | [[Category:Lua-based templates]] | ||
[[Category:Lua-based templates | |||
</includeonly> | </includeonly> | ||
Revision as of 12:13, 4 August 2019
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}}→ 9 January 2009{{date|2009|1|9|pl}}→ 9 stycznia 2009{{date|2009|1|9|pl|case=}}→ 9 stycznia 2009 - alternative way to get nominative case{{date|2009|1|9|pl|case=gen}}→ 9 stycznia 2009{{date|2009|1|9|pl|case=ins}}→ 9 stycznia 2009{{date|2009|1|pl}}→ styczeń 2009{{date|2009|1|pl|form=gen}}→ styczeń 2009{{date|2009|1|pl|form=ins}}→ styczeń 2009{{date|year=888|lang=pl|case=ins|trim_year=yes}}→{{date|year=888|lang=pl|case=ins|trim_year=no}}→{{date|year=888|lang=pl|case=ins|trim_year=100-999}}→{{date|year=888|lang=pl|case=ins|trim_year=100-500}}→
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.
Template parameters
| Parameter | Description | Default | Status | |
|---|---|---|---|---|
1year | year | Year number | empty | optional |
2month | month | Month number or name (in English) | empty | optional |
3day | day | Day number | empty | optional |
hour | hour | Hour number in 0-23 range | empty | optional |
minute | minute | Minutes number in 0-59 range | empty | optional |
second | second | Seconds number in 0-59 range | empty | optional |
4lang | language | Language code (overrides user's preferences) | language code of the user language | optional |
case | case | Allows to specify grammatical case for the month for languages that use them. Possible cases:
| empty | optional |
class | class | 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). See the microformats project. "class=" will remove all metadata. | dtstart | optional |
trim_yeartrim year | trim year | Should years smaller than 1000 be padded with zeros to the length of 4 digits or trimmed. Options:
| 100-999 | optional |
|
<templatedata>JSON</templatedata> ./. {{TemplateBox}}
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 Newly created template documentation and imports Wikipedia's help about TemplateData • Commons-specific information This template is used to show a date in the language set in the preferences. You can leave out parts of the data.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
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:Date
See also
{{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