قالب:ISOdate

Template documentation[view] [edit] [history] [purge]


For a calendar date in ISO 8601 extended format in the form YYYY-MM-DD (e.g. "2024-12-25"), with or without time, this template extracts the year, month, day and time, and calls {{date}} with the year, month and day found to display the date in localised format, with the time, if specified, appended. It provides the convenience of passing on a date (or even a date and a time) from one template to another as a single parameter, even though {{date}} eventually needs the date components separately.

This template overcomes some flaws of the automatic conversion by {{#time: }} for non-full dates (e.g. "77-09" for September 77 AD, which would throw an error with {{#time: }})

Usage

{{ISOdate|1=}}

Parameters

Parameter name Description Default value required or optional?

parameter #1 (1) Any proleptic Gregorian calendar or Gregorian calendar date between 1 January 1 AD and 31 December 9999 AD. Dates BC are not yet supported. Also incomplete dates are allowed: just the year or the year and the month. A year has to be written in full, without leading zeros. Optionally it is followed by a dash and a 2-digit month number; optionally this is followed by a dash and a 2-digit day number; optionally this is followed by the time. empty required
parameter #2 (2) language code (only needs to be provided if the language shall be fixed and independent from the user's preferences) language code of the user language optional
f format ("Y" for year-only output ["{{ISOdate|2008-08-06|f=Y}}" will result in the output "2008"). Similar to {{ISOyear}}. empty optional
form allows to specify grammatical case for the month, for languages that use them. Possible cases: empty optional

Additional information

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

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

Example

{{ISOdate|2009-08-18}}:

renders as:

2009

See also

{{date}}, {{other date}}, {{ISOyear}}

Localization

This template is not intended to be localized.

Example of where the template provides convenience

  • Template:Creator passes on the date of birth and death to e.g. Template:Creator/de and then to Template:Creator/layout. This is done through only two parameters birthdate and deathdate. The last-mentioned template calls this template ISODate to extract the 6 date components, and the time components, if any.

Test cases

{{ISOdate|2010-08-18 08:15:30Z}}: 2010-08-18 08:15:30Z
{{ISOdate|2010-08-18 08:15:30}}: 2010, {{time}} – invalid date format 15 (help)
{{ISOdate|2010-08-18 08:15}}: 2010, {{time}} – invalid date format 15 (help)
{{ISOdate|2010-08-18}}: 2010
{{ISOdate|2010-08}}: 2010
{{ISOdate|2010}}: 2010
{{ISOdate|1970-08-18 08:15:30}}: 1970, {{time}} – invalid date format 15 (help)
{{ISOdate|1969-08-18 08:15:30}}: 1969, {{time}} – invalid date format 15 (help)
{{ISOdate|1800-08-18 08:15:30}}: 1800, {{time}} – invalid date format 15 (help)
{{ISOdate|999-08-18 08:15:30}}: 999, {{time}} – invalid date format 15 (help)
{{ISOdate|119-08-18 08:15:30}}: 119, {{time}} – invalid date format 15 (help)
{{ISOdate|99-08-18 08:15:30}}: 99, {{time}} – invalid date format 15 (help)
{{ISOdate|19-08-18 08:15:30}}: 19, {{time}} – invalid date format 15 (help)
{{ISOdate|9-08-18 08:15:30}}: 9, {{time}} – invalid date format 15 (help)
{{ISOdate|1-08-18 08:15:30}}: 1, {{time}} – invalid date format 15 (help)
{{ISOdate|1970-08-18}}: 1970
{{ISOdate|1969-08-18}}: 1969
{{ISOdate|1800-08-18}}: 1800
{{ISOdate|999-08-18}}: 999
{{ISOdate|119-08-18}}: 119
{{ISOdate|99-08-18}}: 99
{{ISOdate|19-08-18}}: 19
{{ISOdate|9-08-18}}: 9
{{ISOdate|1-08-18}}: 1
{{ISOdate|1970-08}}: 1970
{{ISOdate|1969-08}}: 1969
{{ISOdate|1800-08}}: 1800
{{ISOdate|999-08}}: 999
{{ISOdate|119-08}}: 119
{{ISOdate|99-08}}: 99
{{ISOdate|19-08}}: 19
{{ISOdate|9-08}}: 9
{{ISOdate|1-08}}: 1
{{ISOdate|1970}}: 1970
{{ISOdate|1969}}: 1969
{{ISOdate|1800}}: 1800
{{ISOdate|999}}: 999
{{ISOdate|119}}: 119
{{ISOdate|99}}: 99
{{ISOdate|19}}: 19
{{ISOdate|9}}: 9
{{ISOdate|1}}: 1
{{ISOdate|0}}: 0
{{ISOdate|1567-02-29}}: 1567-02-29
{{ISOdate|2000-02-29}}: 2000
{{ISOdate|f=Y|2010-08-18 08:15:30Z}}: 2010-08-18 08:15:30Z
{{ISOdate|f=Y|2010-08-18 08:15:30}}: 2010
{{ISOdate|f=Y|2010-08-18 08:15}}: 2010
{{ISOdate|f=Y|2010-08-18}}: 2010
{{ISOdate|f=Y|2010-08}}: 2010
{{ISOdate|f=Y|2010}}: 2010
{{ISOdate|f=Y|1970-08-18 08:15:30}}: 1970
{{ISOdate|f=Y|1969-08-18 08:15:30}}: 1969
{{ISOdate|f=Y|1800-08-18 08:15:30}}: 1800
{{ISOdate|f=Y|999-08-18 08:15:30}}: 999
{{ISOdate|f=Y|119-08-18 08:15:30}}: 119
{{ISOdate|f=Y|99-08-18 08:15:30}}: 99
{{ISOdate|f=Y|19-08-18 08:15:30}}: 19
{{ISOdate|f=Y|9-08-18 08:15:30}}: 9
{{ISOdate|f=Y|1-08-18 08:15:30}}: 1
{{ISOdate|f=Y|1970-08-18}}: 1970
{{ISOdate|f=Y|1969-08-18}}: 1969
{{ISOdate|f=Y|1800-08-18}}: 1800
{{ISOdate|f=Y|999-08-18}}: 999
{{ISOdate|f=Y|119-08-18}}: 119
{{ISOdate|f=Y|99-08-18}}: 99
{{ISOdate|f=Y|19-08-18}}: 19
{{ISOdate|f=Y|9-08-18}}: 9
{{ISOdate|f=Y|1-08-18}}: 1
{{ISOdate|f=Y|1970-08}}: 1970
{{ISOdate|f=Y|1969-08}}: 1969
{{ISOdate|f=Y|1800-08}}: 1800
{{ISOdate|f=Y|999-08}}: 999
{{ISOdate|f=Y|119-08}}: 119
{{ISOdate|f=Y|99-08}}: 99
{{ISOdate|f=Y|19-08}}: 19
{{ISOdate|f=Y|9-08}}: 9
{{ISOdate|f=Y|1-08}}: 1
{{ISOdate|f=Y|1970}}: 1970
{{ISOdate|f=Y|1969}}: 1969
{{ISOdate|f=Y|1800}}: 1800
{{ISOdate|f=Y|999}}: 999
{{ISOdate|f=Y|119}}: 119
{{ISOdate|f=Y|99}}: 99
{{ISOdate|f=Y|19}}: 19
{{ISOdate|f=Y|9}}: 9
{{ISOdate|f=Y|1}}: 1
{{ISOdate|f=Y|0}}: 0
{{ISOdate|f=Y|1567-02-29}}: 1567-02-29
{{ISOdate|f=Y|2000-02-29}}: 2000