Difference between revisions of "Template:ISO date"

From blackwiki
Jump to navigation Jump to search
imported>Trödel
(try this instead)
imported>JJMC89
(SAFESUBST)
Line 1: Line 1:
 
<span class="bday dtstart updated"><!-- if formatted MMMM YYYY
 
<span class="bday dtstart updated"><!-- if formatted MMMM YYYY
-->{{ #ifeq: {{{1|}}} | {{ #time: F Y | {{{1|}}} | local }}|<!--  
+
-->{{SAFESUBST:<noinclude/> #ifeq: {{{1|}}} | {{SAFESUBST:<noinclude/> #time: F Y | {{{1|}}} | local }}|<!--  
   then -->{{ #time: Y-m | {{{1|}}} | local }}|<!--
+
   then -->{{SAFESUBST:<noinclude/> #time: Y-m | {{{1|}}} | local }}|<!--
 
   else if formatted MMM YYYY
 
   else if formatted MMM YYYY
       -->{{ #ifeq: {{{1|}}} | {{ #time: M Y | {{{1|}}} | local }}|<!--  
+
       -->{{SAFESUBST:<noinclude/> #ifeq: {{{1|}}} | {{SAFESUBST:<noinclude/> #time: M Y | {{{1|}}} | local }}|<!--  
       then -->{{ #time: Y-m | {{{1|}}} | local }}|<!--
+
       then -->{{SAFESUBST:<noinclude/> #time: Y-m | {{{1|}}} | local }}|<!--
 
       else if formatted YYYY
 
       else if formatted YYYY
         -->{{ #ifeq: {{{1|}}} | {{ #time: Y | 0:01 {{{1|<noinclude>15 January 2001</noinclude>}}} | local }}|<!--  
+
         -->{{SAFESUBST:<noinclude/> #ifeq: {{{1|}}} | {{SAFESUBST:<noinclude/> #time: Y | 0:01 {{{1|<noinclude>15 January 2001</noinclude>}}} | local }}|<!--  
         then -->{{#if:{{{1|<noinclude>15 January 2001</noinclude>}}}|{{{1}}}|<span class="error">ISO date requires a parameter</span>}}|<!--  
+
         then -->{{SAFESUBST:<noinclude/>#if:{{{1|<noinclude>15 January 2001</noinclude>}}}|{{{1}}}|<span class="error">ISO date requires a parameter</span>}}|<!--  
 
         else format general case as regular date
 
         else format general case as regular date
             -->{{ #time: Y-m-d |{{{1|<noinclude>15 January 2001</noinclude>}}}|local}}<!--
+
             -->{{SAFESUBST:<noinclude/> #time: Y-m-d |{{{1|<noinclude>15 January 2001</noinclude>}}}|local}}<!--
 
         end if-->}}<!--
 
         end if-->}}<!--
 
   end if-->}}<!--
 
   end if-->}}<!--

Revision as of 00:17, 11 January 2016

{{SAFESUBST: #ifeq: | {{SAFESUBST: #time: F Y | | local }}|{{SAFESUBST: #time: Y-m | | local }}|{{SAFESUBST: #ifeq: | {{SAFESUBST: #time: M Y | | local }}|{{SAFESUBST: #time: Y-m | | local }}|{{SAFESUBST: #ifeq: | {{SAFESUBST: #time: Y | 0:01 15 January 2001 | local }}|{{{1}}}|{{SAFESUBST: #time: Y-m-d |15 January 2001|local}}}}}}}}

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

This template converts dates to ISO dates (YYYY-MM-DD or YYYY-MM or YYYY as appropriate), see below for restrictions on input formats accepted.

Usage

The template may be used without any parameters, in which case it displays the current date: If no year has been specified, it displays the current year

  • {{ISO date|Aug 17}} returns {{SAFESUBST: #ifeq: Aug 17 | {{SAFESUBST: #time: F Y | Aug 17 | local }}|{{SAFESUBST: #time: Y-m | Aug 17 | local }}|{{SAFESUBST: #ifeq: Aug 17 | {{SAFESUBST: #time: M Y | Aug 17 | local }}|{{SAFESUBST: #time: Y-m | Aug 17 | local }}|{{SAFESUBST: #ifeq: Aug 17 | {{SAFESUBST: #time: Y | 0:01 Aug 17 | local }}|Aug 17|{{SAFESUBST: #time: Y-m-d |Aug 17|local}}}}}}}}
  • {{ISO date}} returns {{SAFESUBST: #ifeq: | {{SAFESUBST: #time: F Y | | local }}|{{SAFESUBST: #time: Y-m | | local }}|{{SAFESUBST: #ifeq: | {{SAFESUBST: #time: M Y | | local }}|{{SAFESUBST: #time: Y-m | | local }}|{{SAFESUBST: #ifeq: | {{SAFESUBST: #time: Y | 0:01 | local }}|ISO date requires a parameter|{{SAFESUBST: #time: Y-m-d ||local}}}}}}}}

The template accepts one unnamed parameter containing a date in one of the following formats:

  • {{ISO date|15 January 2001}} returns {{SAFESUBST: #ifeq: 15 January 2001 | {{SAFESUBST: #time: F Y | 15 January 2001 | local }}|{{SAFESUBST: #time: Y-m | 15 January 2001 | local }}|{{SAFESUBST: #ifeq: 15 January 2001 | {{SAFESUBST: #time: M Y | 15 January 2001 | local }}|{{SAFESUBST: #time: Y-m | 15 January 2001 | local }}|{{SAFESUBST: #ifeq: 15 January 2001 | {{SAFESUBST: #time: Y | 0:01 15 January 2001 | local }}|15 January 2001|{{SAFESUBST: #time: Y-m-d |15 January 2001|local}}}}}}}}
  • {{ISO date|15 Jan 2001}} returns {{SAFESUBST: #ifeq: 15 Jan 2001 | {{SAFESUBST: #time: F Y | 15 Jan 2001 | local }}|{{SAFESUBST: #time: Y-m | 15 Jan 2001 | local }}|{{SAFESUBST: #ifeq: 15 Jan 2001 | {{SAFESUBST: #time: M Y | 15 Jan 2001 | local }}|{{SAFESUBST: #time: Y-m | 15 Jan 2001 | local }}|{{SAFESUBST: #ifeq: 15 Jan 2001 | {{SAFESUBST: #time: Y | 0:01 15 Jan 2001 | local }}|15 Jan 2001|{{SAFESUBST: #time: Y-m-d |15 Jan 2001|local}}}}}}}}
  • {{ISO date|15-01-2001}} returns {{SAFESUBST: #ifeq: 15-01-2001 | {{SAFESUBST: #time: F Y | 15-01-2001 | local }}|{{SAFESUBST: #time: Y-m | 15-01-2001 | local }}|{{SAFESUBST: #ifeq: 15-01-2001 | {{SAFESUBST: #time: M Y | 15-01-2001 | local }}|{{SAFESUBST: #time: Y-m | 15-01-2001 | local }}|{{SAFESUBST: #ifeq: 15-01-2001 | {{SAFESUBST: #time: Y | 0:01 15-01-2001 | local }}|15-01-2001|{{SAFESUBST: #time: Y-m-d |15-01-2001|local}}}}}}}}
  • {{ISO date|January 15, 2001}} returns {{SAFESUBST: #ifeq: January 15, 2001 | {{SAFESUBST: #time: F Y | January 15, 2001 | local }}|{{SAFESUBST: #time: Y-m | January 15, 2001 | local }}|{{SAFESUBST: #ifeq: January 15, 2001 | {{SAFESUBST: #time: M Y | January 15, 2001 | local }}|{{SAFESUBST: #time: Y-m | January 15, 2001 | local }}|{{SAFESUBST: #ifeq: January 15, 2001 | {{SAFESUBST: #time: Y | 0:01 January 15, 2001 | local }}|January 15, 2001|{{SAFESUBST: #time: Y-m-d |January 15, 2001|local}}}}}}}}
  • {{ISO date|Jan 15, 2001}} returns {{SAFESUBST: #ifeq: Jan 15, 2001 | {{SAFESUBST: #time: F Y | Jan 15, 2001 | local }}|{{SAFESUBST: #time: Y-m | Jan 15, 2001 | local }}|{{SAFESUBST: #ifeq: Jan 15, 2001 | {{SAFESUBST: #time: M Y | Jan 15, 2001 | local }}|{{SAFESUBST: #time: Y-m | Jan 15, 2001 | local }}|{{SAFESUBST: #ifeq: Jan 15, 2001 | {{SAFESUBST: #time: Y | 0:01 Jan 15, 2001 | local }}|Jan 15, 2001|{{SAFESUBST: #time: Y-m-d |Jan 15, 2001|local}}}}}}}}
  • {{ISO date|Jan. 15, 2001}} returns {{SAFESUBST: #ifeq: Jan. 15, 2001 | {{SAFESUBST: #time: F Y | Jan. 15, 2001 | local }}|{{SAFESUBST: #time: Y-m | Jan. 15, 2001 | local }}|{{SAFESUBST: #ifeq: Jan. 15, 2001 | {{SAFESUBST: #time: M Y | Jan. 15, 2001 | local }}|{{SAFESUBST: #time: Y-m | Jan. 15, 2001 | local }}|{{SAFESUBST: #ifeq: Jan. 15, 2001 | {{SAFESUBST: #time: Y | 0:01 Jan. 15, 2001 | local }}|Jan. 15, 2001|{{SAFESUBST: #time: Y-m-d |Jan. 15, 2001|local}}}}}}}}
  • {{ISO date|01/15/2001}} returns {{SAFESUBST: #ifeq: 01/15/2001 | {{SAFESUBST: #time: F Y | 01/15/2001 | local }}|{{SAFESUBST: #time: Y-m | 01/15/2001 | local }}|{{SAFESUBST: #ifeq: 01/15/2001 | {{SAFESUBST: #time: M Y | 01/15/2001 | local }}|{{SAFESUBST: #time: Y-m | 01/15/2001 | local }}|{{SAFESUBST: #ifeq: 01/15/2001 | {{SAFESUBST: #time: Y | 0:01 01/15/2001 | local }}|01/15/2001|{{SAFESUBST: #time: Y-m-d |01/15/2001|local}}}}}}}}
  • {{ISO date|January 2001}} returns {{SAFESUBST: #ifeq: January 2001 | {{SAFESUBST: #time: F Y | January 2001 | local }}|{{SAFESUBST: #time: Y-m | January 2001 | local }}|{{SAFESUBST: #ifeq: January 2001 | {{SAFESUBST: #time: M Y | January 2001 | local }}|{{SAFESUBST: #time: Y-m | January 2001 | local }}|{{SAFESUBST: #ifeq: January 2001 | {{SAFESUBST: #time: Y | 0:01 January 2001 | local }}|January 2001|{{SAFESUBST: #time: Y-m-d |January 2001|local}}}}}}}}
  • {{ISO date|Jan 2001}} returns {{SAFESUBST: #ifeq: Jan 2001 | {{SAFESUBST: #time: F Y | Jan 2001 | local }}|{{SAFESUBST: #time: Y-m | Jan 2001 | local }}|{{SAFESUBST: #ifeq: Jan 2001 | {{SAFESUBST: #time: M Y | Jan 2001 | local }}|{{SAFESUBST: #time: Y-m | Jan 2001 | local }}|{{SAFESUBST: #ifeq: Jan 2001 | {{SAFESUBST: #time: Y | 0:01 Jan 2001 | local }}|Jan 2001|{{SAFESUBST: #time: Y-m-d |Jan 2001|local}}}}}}}}
  • {{ISO date|2001}} returns {{SAFESUBST: #ifeq: 2001 | {{SAFESUBST: #time: F Y | 2001 | local }}|{{SAFESUBST: #time: Y-m | 2001 | local }}|{{SAFESUBST: #ifeq: 2001 | {{SAFESUBST: #time: M Y | 2001 | local }}|{{SAFESUBST: #time: Y-m | 2001 | local }}|{{SAFESUBST: #ifeq: 2001 | {{SAFESUBST: #time: Y | 0:01 2001 | local }}|2001|{{SAFESUBST: #time: Y-m-d |2001|local}}}}}}}}

Formats for which it can not work because #time returns an error or an incorrect ISO format:

  • {{ISO date|01-15-2001}} returns {{SAFESUBST: #ifeq: 01-15-2001 | {{SAFESUBST: #time: F Y | 01-15-2001 | local }}|{{SAFESUBST: #time: Y-m | 01-15-2001 | local }}|{{SAFESUBST: #ifeq: 01-15-2001 | {{SAFESUBST: #time: M Y | 01-15-2001 | local }}|{{SAFESUBST: #time: Y-m | 01-15-2001 | local }}|{{SAFESUBST: #ifeq: 01-15-2001 | {{SAFESUBST: #time: Y | 0:01 01-15-2001 | local }}|01-15-2001|{{SAFESUBST: #time: Y-m-d |01-15-2001|local}}}}}}}} (hyphens indicate DD-MM-YYYY and 15 is an invalid month number)
  • {{ISO date|15/01/2001}} returns {{SAFESUBST: #ifeq: 15/01/2001 | {{SAFESUBST: #time: F Y | 15/01/2001 | local }}|{{SAFESUBST: #time: Y-m | 15/01/2001 | local }}|{{SAFESUBST: #ifeq: 15/01/2001 | {{SAFESUBST: #time: M Y | 15/01/2001 | local }}|{{SAFESUBST: #time: Y-m | 15/01/2001 | local }}|{{SAFESUBST: #ifeq: 15/01/2001 | {{SAFESUBST: #time: Y | 0:01 15/01/2001 | local }}|15/01/2001|{{SAFESUBST: #time: Y-m-d |15/01/2001|local}}}}}}}} (slashes indicate MM/DD/YYYY and 15 is an invalid month number)
  • {{ISO date|1/2001}} returns {{SAFESUBST: #ifeq: 1/2001 | {{SAFESUBST: #time: F Y | 1/2001 | local }}|{{SAFESUBST: #time: Y-m | 1/2001 | local }}|{{SAFESUBST: #ifeq: 1/2001 | {{SAFESUBST: #time: M Y | 1/2001 | local }}|{{SAFESUBST: #time: Y-m | 1/2001 | local }}|{{SAFESUBST: #ifeq: 1/2001 | {{SAFESUBST: #time: Y | 0:01 1/2001 | local }}|1/2001|{{SAFESUBST: #time: Y-m-d |1/2001|local}}}}}}}}
  • {{ISO date|2001 January 15}} returns {{SAFESUBST: #ifeq: 2001 January 15 | {{SAFESUBST: #time: F Y | 2001 January 15 | local }}|{{SAFESUBST: #time: Y-m | 2001 January 15 | local }}|{{SAFESUBST: #ifeq: 2001 January 15 | {{SAFESUBST: #time: M Y | 2001 January 15 | local }}|{{SAFESUBST: #time: Y-m | 2001 January 15 | local }}|{{SAFESUBST: #ifeq: 2001 January 15 | {{SAFESUBST: #time: Y | 0:01 2001 January 15 | local }}|2001 January 15|{{SAFESUBST: #time: Y-m-d |2001 January 15|local}}}}}}}}
  • {{ISO date|2001 January}} returns {{SAFESUBST: #ifeq: 2001 January | {{SAFESUBST: #time: F Y | 2001 January | local }}|{{SAFESUBST: #time: Y-m | 2001 January | local }}|{{SAFESUBST: #ifeq: 2001 January | {{SAFESUBST: #time: M Y | 2001 January | local }}|{{SAFESUBST: #time: Y-m | 2001 January | local }}|{{SAFESUBST: #ifeq: 2001 January | {{SAFESUBST: #time: Y | 0:01 2001 January | local }}|2001 January|{{SAFESUBST: #time: Y-m-d |2001 January|local}}}}}}}} (expected: {{SAFESUBST: #ifeq: January 2001 | {{SAFESUBST: #time: F Y | January 2001 | local }}|{{SAFESUBST: #time: Y-m | January 2001 | local }}|{{SAFESUBST: #ifeq: January 2001 | {{SAFESUBST: #time: M Y | January 2001 | local }}|{{SAFESUBST: #time: Y-m | January 2001 | local }}|{{SAFESUBST: #ifeq: January 2001 | {{SAFESUBST: #time: Y | 0:01 January 2001 | local }}|January 2001|{{SAFESUBST: #time: Y-m-d |January 2001|local}}}}}}}})

Use in microformats

Template:UF-date-part

See also