Changes

Jump to navigation Jump to search
update
{{Documentation subpage}}
<!-- Place categories where indicated at the bottom of this page and interwikis at Wikidata -->
{{Lua|Module:YMD to ISO}}

'''{{NAMESPACE}}:{{BASEPAGENAME}}''' converts a date in [[Calendar date#Gregorian, year-month-day (YMD)|YMD]] format (e.g. 2000 January 17) to [[ISO 8601]] format (e.g. 2000-01-17). Any input which is not a valid DMY date is passed through unchanged. This template is designed to [[wikt:preprocess|preprocess]] dates for use with the [[Help:Time function|#time]] parser function, which is unable to convert YMD dates, and for use with templates such as {{tl|Date}} or {{tl|ISO date}} which are implemented using the #time parser function.

== Usage ==
: <code><nowiki>{{</nowiki>{{BASEPAGENAME}} | ''<date in YMD format>'' }}</code>

== Examples ==
=== Full month names ===
* <tt><nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki>| 2000 January 17 }}</nowiki></tt> → {{{{BASEPAGENAME}}| 2000 January 17 }}
* <tt><nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki>|2000 February 29}}</nowiki></tt> → {{{{BASEPAGENAME}}|2000 February 29}}
* <tt><nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki>|2001 February 28}}</nowiki></tt> → {{{{BASEPAGENAME}}|2001 February 28}}
* <tt><nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki>|2000 december 17}}</nowiki></tt> → {{{{BASEPAGENAME}}|2000 december 17}}
* <tt><nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki>|2000 DECEMBER 17}}</nowiki></tt> → {{{{BASEPAGENAME}}|2000 DECEMBER 17}}

=== Abbreviated month names ===
* <tt><nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki>|2000 Sep 1}}</nowiki></tt> → {{{{BASEPAGENAME}}|2000 Sep 1}}
* <tt><nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki>|2000 Sept 1}}</nowiki></tt> → {{{{BASEPAGENAME}}|2000 Sept 1}}
* <tt><nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki>|2000 Sept. 1}}</nowiki></tt> → {{{{BASEPAGENAME}}|2000 Sept. 1}}
* <tt><nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki>|2000 dec 1}}</nowiki></tt> → {{{{BASEPAGENAME}}|2000 dec 1}}
* <tt><nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki>|2000 DEC. 1}}</nowiki></tt> → {{{{BASEPAGENAME}}|2000 DEC. 1}}

=== Dates in other formats (unchanged) ===
* <tt><nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki>|1 December 2000}}</nowiki></tt> → {{{{BASEPAGENAME}}|1 December 2000}}
* <tt><nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki>|December 1, 2000}}</nowiki></tt> → {{{{BASEPAGENAME}}|December 1, 2000}}

=== Used as input ===
With the {{[[Help:Time function|#time]]}} parser function:
* <tt><nowiki>{{#time: r|{{</nowiki>{{BASEPAGENAME}}<nowiki>|2000 January 17}}}}</nowiki></tt> → {{#time: r|{{{{BASEPAGENAME}}|2000 January 17}}}}
* without {{Braces|{{BASEPAGENAME}}}}: <tt><nowiki>{{#time: r|2000 January 17}}</nowiki></tt> → {{#time: r|2000 January 17}}

With the {{tl|Date}} template:
* <tt><nowiki>{{Date|{{</nowiki>{{BASEPAGENAME}}<nowiki>|2000 January 17}}|dmy}}</nowiki></tt> → {{Date|{{{{BASEPAGENAME}}|2000 January 17}}|dmy}}
* without {{Braces|{{BASEPAGENAME}}}}: <tt><nowiki>{{Date|2000 January 17|dmy}}</nowiki></tt> → {{Date|2000 January 17|dmy}} ''(not converted to dmy)''

With the {{tl|ISO date}} template:
* <tt><nowiki>{{ISO date|{{</nowiki>{{BASEPAGENAME}}<nowiki>|2000 January 17}}|dmy}}</nowiki></tt> → {{ISO date|{{{{BASEPAGENAME}}|2000 January 17}}|dmy}}
* without {{Braces|{{BASEPAGENAME}}}}: <tt><nowiki>{{ISO date|2000 January 17|dmy}}</nowiki></tt> → {{ISO date|2000 January 17|dmy}}

== See also ==
* [[Template:YMD to ISO/testcases]]
* [[Help:Time function]]
* {{Section link|mw:Help:Extension:ParserFunctions|#time}}

{{Hidden|Date and time templates|{{Date and time templates}}|style=border:1px solid gray;|headerstyle=background-color:lightsteelblue; text-align:left; padding-left:2em;}}

<includeonly>{{sandbox other||
<!-- Categories below this line; interwikis at Wikidata -->
[[Category:Date conversion templates]]
[[Category:ISO date templates]]

}}</includeonly>
Anonymous user

Navigation menu