Difference between revisions of "Template:ISO date/doc"

From blackwiki
Jump to navigation Jump to search
imported>Zyxw
(update examples)
imported>Jonesey95
m (Fix Linter errors using AutoEd)
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
{{Documentation subpage}}
 
{{Documentation subpage}}
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
+
<!-- Place categories where indicated at the bottom of this page and interwikis at Wikidata -->
This template converts dates to YYYY-MM-DD or YYYY-MM or YYYY as appropriate - see below for restrictions on input formats accepted.
+
 
 +
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 ==
 
== Usage ==
This template only converts dates formatted in one of the formats below to an ISO date  
+
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
 +
 
 +
* <code><nowiki>{{ISO date|Aug 17}}</nowiki></code> returns {{ISO date|Aug 17}}<br />
 +
* <code><nowiki>{{ISO date}}</nowiki></code> returns {{ISO date}}
  
 
The template accepts one unnamed parameter containing a date in one of the following formats:
 
The template accepts one unnamed parameter containing a date in one of the following formats:
  
* <tt><nowiki>{{ISO date|15 January 2001}}</nowiki><tt> returns {{ISO date|15 January 2001}}
+
* <code><nowiki>{{ISO date|15 January 2001}}</nowiki></code> returns {{ISO date|15 January 2001}}
* <tt><nowiki>{{ISO date|15 Jan 2001}}</nowiki><tt> returns {{ISO date|15 Jan 2001}}
+
* <code><nowiki>{{ISO date|15 Jan 2001}}</nowiki></code> returns {{ISO date|15 Jan 2001}}
* <tt><nowiki>{{ISO date|15-01-2001}}</nowiki><tt> returns {{ISO date|15-01-2001}}
+
* <code><nowiki>{{ISO date|15-01-2001}}</nowiki></code> returns {{ISO date|15-01-2001}}
  
* <tt><nowiki>{{ISO date|January 15, 2001}}</nowiki><tt> returns {{ISO date|January 15, 2001}}
+
* <code><nowiki>{{ISO date|January 15, 2001}}</nowiki></code> returns {{ISO date|January 15, 2001}}
* <tt><nowiki>{{ISO date|Jan 15, 2001}}</nowiki><tt> returns {{ISO date|Jan 15, 2001}}
+
* <code><nowiki>{{ISO date|Jan 15, 2001}}</nowiki></code> returns {{ISO date|Jan 15, 2001}}
* <tt><nowiki>{{ISO date|Jan. 15, 2001}}</nowiki><tt> returns {{ISO date|Jan. 15, 2001}}
+
* <code><nowiki>{{ISO date|Jan. 15, 2001}}</nowiki></code> returns {{ISO date|Jan. 15, 2001}}
* <tt><nowiki>{{ISO date|01/15/2001}}</nowiki><tt> returns {{ISO date|01/15/2001}}
+
* <code><nowiki>{{ISO date|01/15/2001}}</nowiki></code> returns {{ISO date|01/15/2001}}
  
* <tt><nowiki>{{ISO date|January 2001}}</nowiki><tt> returns {{ISO date|January 2001}}
+
* <code><nowiki>{{ISO date|January 2001}}</nowiki></code> returns {{ISO date|January 2001}}
* <tt><nowiki>{{ISO date|Jan 2001}}</nowiki><tt> returns {{ISO date|Jan 2001}}
+
* <code><nowiki>{{ISO date|Jan 2001}}</nowiki></code> returns {{ISO date|Jan 2001}}
  
* <tt><nowiki>{{ISO date|2001}}</nowiki><tt> returns {{ISO date|2001}}
+
* <code><nowiki>{{ISO date|2001}}</nowiki></code> returns {{ISO date|2001}}
  
 
Formats for which it can not work because [[Help:Time function|#time]] returns an error or an incorrect ISO format:
 
Formats for which it can not work because [[Help:Time function|#time]] returns an error or an incorrect ISO format:
* <tt><nowiki>{{ISO date|01-15-2001}}</nowiki><tt> returns {{ISO date|01-15-2001}} ''(hyphens indicate DD-MM-YYYY and 15 is an invalid month number)''
+
 
* <tt><nowiki>{{ISO date|15/01/2001}}</nowiki><tt> returns {{ISO date|15/01/2001}} ''(slashes indicate MM/DD/YYYY and 15 is an invalid month number)''
+
* <code><nowiki>{{ISO date|01-15-2001}}</nowiki></code> returns {{ISO date|01-15-2001}} ''(hyphens indicate DD-MM-YYYY and 15 is an invalid month number)''
* <tt><nowiki>{{ISO date|1/2001}}</nowiki><tt> returns {{ISO date|1/2001}}
+
* <code><nowiki>{{ISO date|15/01/2001}}</nowiki></code> returns {{ISO date|15/01/2001}} ''(slashes indicate MM/DD/YYYY and 15 is an invalid month number)''
* <tt><nowiki>{{ISO date|2001 January 15}}</nowiki><tt> returns {{ISO date|2001 January 15}}
+
* <code><nowiki>{{ISO date|1/2001}}</nowiki></code> returns {{ISO date|1/2001}}
* <tt><nowiki>{{ISO date|2001 January}}</nowiki><tt> returns {{ISO date|2001 January}} ''(expected: {{ISO date|January 2001}})''
+
* <code><nowiki>{{ISO date|2001 January 15}}</nowiki></code> returns {{ISO date|2001 January 15}}
 +
* <code><nowiki>{{ISO date|2001 January}}</nowiki></code> returns {{ISO date|2001 January}} ''(expected: {{ISO date|January 2001}})''
  
 
== Use in microformats ==
 
== Use in microformats ==
Line 37: Line 44:
 
* {{Tl|Start date}}
 
* {{Tl|Start date}}
  
<includeonly>
+
<includeonly>{{sandbox other||
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
+
<!-- Categories below this line; interwikis at Wikidata -->
 
[[Category:ISO date templates]]
 
[[Category:ISO date templates]]
[[Category:Date mathematics templates|{{PAGENAME}}]]
+
[[Category:Date conversion templates]]
[[Category:Templates generating hAtom|{{PAGENAME}}]]
+
[[Category:Date-computing templates]]
[[Category:Templates generating hCalendars|{{PAGENAME}}]]
+
[[Category:Templates generating hAtom]]
[[Category:Templates generating hCards|{{PAGENAME}}]]
+
[[Category:Templates generating hCalendars]]
 +
[[Category:Templates generating hCards]]
  
</includeonly>
+
}}</includeonly>

Latest revision as of 15:17, 31 May 2020

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 2026-08-17
  • {{ISO date}} returns 2026-01-14

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

  • {{ISO date|15 January 2001}} returns 2001-01-15
  • {{ISO date|15 Jan 2001}} returns 2001-01-15
  • {{ISO date|15-01-2001}} returns 2001-01-15
  • {{ISO date|January 15, 2001}} returns 2001-01-15
  • {{ISO date|Jan 15, 2001}} returns 2001-01-15
  • {{ISO date|Jan. 15, 2001}} returns 2001-01-15
  • {{ISO date|01/15/2001}} returns 2001-01-15
  • {{ISO date|January 2001}} returns 2001-01
  • {{ISO date|Jan 2001}} returns 2001-01
  • {{ISO date|2001}} returns 2001

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

  • {{ISO date|01-15-2001}} returns Error: Invalid time. (hyphens indicate DD-MM-YYYY and 15 is an invalid month number)
  • {{ISO date|15/01/2001}} returns Error: Invalid time. (slashes indicate MM/DD/YYYY and 15 is an invalid month number)
  • {{ISO date|1/2001}} returns Error: Invalid time.
  • {{ISO date|2001 January 15}} returns Error: Invalid time.
  • {{ISO date|2001 January}} returns 2001-01-01 (expected: 2001-01)

Use in microformats

Template:UF-date-part

See also