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

From blackwiki
Jump to navigation Jump to search
imported>Pigsonthewing
imported>Jonesey95
m (Fix Linter errors using AutoEd)
 
(7 intermediate revisions by 5 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 formated 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:
 +
 
 +
* <code><nowiki>{{ISO date|15 January 2001}}</nowiki></code> returns {{ISO date|15 January 2001}}
 +
* <code><nowiki>{{ISO date|15 Jan 2001}}</nowiki></code> returns {{ISO date|15 Jan 2001}}
 +
* <code><nowiki>{{ISO date|15-01-2001}}</nowiki></code> returns {{ISO date|15-01-2001}}
 +
 
 +
* <code><nowiki>{{ISO date|January 15, 2001}}</nowiki></code> returns {{ISO date|January 15, 2001}}
 +
* <code><nowiki>{{ISO date|Jan 15, 2001}}</nowiki></code> returns {{ISO date|Jan 15, 2001}}
 +
* <code><nowiki>{{ISO date|Jan. 15, 2001}}</nowiki></code> returns {{ISO date|Jan. 15, 2001}}
 +
* <code><nowiki>{{ISO date|01/15/2001}}</nowiki></code> returns {{ISO date|01/15/2001}}
  
The template accepts one parameter - which must be unnamed. For example:
+
* <code><nowiki>{{ISO date|January 2001}}</nowiki></code> returns {{ISO date|January 2001}}
 +
* <code><nowiki>{{ISO date|Jan 2001}}</nowiki></code> returns {{ISO date|Jan 2001}}
  
*{<nowiki>{</nowiki>ISO date|15 January 2001}} returns {{ISO date|15 January 2001}}  
+
* <code><nowiki>{{ISO date|2001}}</nowiki></code> returns {{ISO date|2001}}
*{<nowiki>{</nowiki>ISO date|March 2003}} returns {{ISO date|March 2003}}
 
  
The date parameter must be in one of the following formats:
+
Formats for which it can not work because [[Help:Time function|#time]] returns an error or an incorrect ISO format:
* 15 January 2001
 
* 15 Jan 2001
 
* January 15, 2001
 
* Jan 15, 2001
 
* 15-01-2001
 
* January 2001
 
* Jan 2001
 
* 2001
 
  
Formats for which it can not work because #time returns an error:
+
* <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)''
* 01-15-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)''
* 1/2001
+
* <code><nowiki>{{ISO date|1/2001}}</nowiki></code> returns {{ISO date|1/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 ==
 
 
{{UF-date-part}}
 
{{UF-date-part}}
  
 
== See also ==
 
== See also ==
 +
* {{Tl|ISO end date}}
 +
* {{Tl|Birth date}}
 +
* {{Tl|Birth date and age}}
 +
* {{Tl|Start date}}
  
*{{Tl|ISO end date}}
+
<includeonly>{{sandbox other||
*{{Tl|Birth date}}
+
<!-- Categories below this line; interwikis at Wikidata -->
*{{Tl|Birth date and age}}
 
*{{Tl|Start date}}
 
 
 
<includeonly>
 
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
 
 
[[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