Template
YMD to ISO/doc
From Dogcraft Wiki
(from wikipedia (https://en.wikipedia.org/w/index.php?title=Template:YMD_to_ISO/doc)) |
m (Text replacement - "{{tl|" to "{{template link|") |
||
Line 3: | Line 3: | ||
{{Lua|Module:YMD to ISO}} | {{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 {{ | '''{{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 {{template link|Date}} or {{template link|ISO date}} which are implemented using the #time parser function. | ||
== Usage == | == Usage == | ||
Line 32: | Line 32: | ||
* without {{Braces|{{BASEPAGENAME}}}}: <code><nowiki>{{#time: r|2000 January 17}}</nowiki></code> → {{#time: r|2000 January 17}} | * without {{Braces|{{BASEPAGENAME}}}}: <code><nowiki>{{#time: r|2000 January 17}}</nowiki></code> → {{#time: r|2000 January 17}} | ||
With the {{ | With the {{template link|Date}} template: | ||
* <code><nowiki>{{Date|{{</nowiki>{{BASEPAGENAME}}<nowiki>|2000 January 17}}|dmy}}</nowiki></code> → {{Date|{{{{BASEPAGENAME}}|2000 January 17}}|dmy}} | * <code><nowiki>{{Date|{{</nowiki>{{BASEPAGENAME}}<nowiki>|2000 January 17}}|dmy}}</nowiki></code> → {{Date|{{{{BASEPAGENAME}}|2000 January 17}}|dmy}} | ||
* without {{Braces|{{BASEPAGENAME}}}}: <code><nowiki>{{Date|2000 January 17|dmy}}</nowiki></code> → {{Date|2000 January 17|dmy}} ''(not converted to dmy)'' | * without {{Braces|{{BASEPAGENAME}}}}: <code><nowiki>{{Date|2000 January 17|dmy}}</nowiki></code> → {{Date|2000 January 17|dmy}} ''(not converted to dmy)'' | ||
With the {{ | With the {{template link|ISO date}} template: | ||
* <code><nowiki>{{ISO date|{{</nowiki>{{BASEPAGENAME}}<nowiki>|2000 January 17}}|dmy}}</nowiki></code> → {{ISO date|{{{{BASEPAGENAME}}|2000 January 17}}|dmy}} | * <code><nowiki>{{ISO date|{{</nowiki>{{BASEPAGENAME}}<nowiki>|2000 January 17}}|dmy}}</nowiki></code> → {{ISO date|{{{{BASEPAGENAME}}|2000 January 17}}|dmy}} | ||
* without {{Braces|{{BASEPAGENAME}}}}: <code><nowiki>{{ISO date|2000 January 17|dmy}}</nowiki></code> → {{ISO date|2000 January 17|dmy}} | * without {{Braces|{{BASEPAGENAME}}}}: <code><nowiki>{{ISO date|2000 January 17|dmy}}</nowiki></code> → {{ISO date|2000 January 17|dmy}} |
Revision as of 23:06, 3 December 2023
This is a documentation subpage for Template:YMD to ISO. It contains usage information, categories and other content that is not part of the original template page. |
Script error: No such module "Lua banner".
Template:YMD to ISO converts a date in 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 preprocess dates for use with the #time parser function, which is unable to convert YMD dates, and for use with templates such as {{Date}} or {{ISO date}} which are implemented using the #time parser function.
Usage
{{YMD to ISO | <date in YMD format> }}
Examples
Full month names
{{YMD to ISO| 2000 January 17 }}
→ 2000-01-17{{YMD to ISO|2000 February 29}}
→ 2000-02-29{{YMD to ISO|2001 February 28}}
→ 2001-02-28{{YMD to ISO|2000 december 17}}
→ 2000-12-17{{YMD to ISO|2000 DECEMBER 17}}
→ 2000-12-17
Abbreviated month names
{{YMD to ISO|2000 Sep 1}}
→ 2000-09-01{{YMD to ISO|2000 Sept 1}}
→ 2000-09-01{{YMD to ISO|2000 Sept. 1}}
→ 2000-09-01{{YMD to ISO|2000 dec 1}}
→ 2000-12-01{{YMD to ISO|2000 DEC. 1}}
→ 2000-12-01
Dates in other formats (unchanged)
{{YMD to ISO|1 December 2000}}
→ 1 December 2000{{YMD to ISO|December 1, 2000}}
→ December 1, 2000
Used as input
With the {{#time}} parser function:
{{#time: r|{{YMD to ISO|2000 January 17}}}}
→ Mon, 17 Jan 2000 00:00:00 +0000- without Template:Braces:
{{#time: r|2000 January 17}}
→ Error: Invalid time.
With the {{Date}} template:
{{Date|{{YMD to ISO|2000 January 17}}|dmy}}
→ Template:Date- without Template:Braces:
{{Date|2000 January 17|dmy}}
→ Template:Date (not converted to dmy)
With the {{ISO date}} template:
{{ISO date|{{YMD to ISO|2000 January 17}}|dmy}}
→ Template:ISO date- without Template:Braces:
{{ISO date|2000 January 17|dmy}}
→ Template:ISO date
See also
This page was last modified on 3 December 2023, at 23:06. (11 months ago)