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

From blackwiki
Jump to navigation Jump to search
imported>Trödel
(edit summary)
imported>Jonesey95
m (Fix Linter errors using AutoEd)
 
(14 intermediate revisions by 8 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.
 
=== Usage ===
 
This template only converts dates formated in one of these formats to an ISO date (a generalized version exists in the history but it will not work consistently because of the number of #time codes used in the calling template.
 
  
The template accepts one parameter - which must be unnamed. For example:
+
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.
  
*{<nowiki>{</nowiki>ISO date|15 January 2001}} returns {{ISO date|15 January 2001}}
+
== Usage ==
*{<nowiki>{</nowiki>ISO date|March 2003}} returns {{ISO date|March 2003}}
+
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
  
The date parameter must be in one of the following formats:
+
* <code><nowiki>{{ISO date|Aug 17}}</nowiki></code> returns {{ISO date|Aug 17}}<br />
* 15 January 2001
+
* <code><nowiki>{{ISO date}}</nowiki></code> returns {{ISO date}}
* 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:
+
The template accepts one unnamed parameter containing a date in one of the following formats:
* 01-15-2001
 
* 1/2001
 
  
=== See also ===
+
* <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}}
  
<includeonly>
+
* <code><nowiki>{{ISO date|January 15, 2001}}</nowiki></code> returns {{ISO date|January 15, 2001}}
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
+
* <code><nowiki>{{ISO date|Jan 15, 2001}}</nowiki></code> returns {{ISO date|Jan 15, 2001}}
[[Category:Date mathematics templates|ISO date]]
+
* <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}}
  
 +
* <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}}
  
</includeonly>
+
* <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:
 +
 
 +
* <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)''
 +
* <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)''
 +
* <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 ==
 +
{{UF-date-part}}
 +
 
 +
== See also ==
 +
* {{Tl|ISO end date}}
 +
* {{Tl|Birth date}}
 +
* {{Tl|Birth date and age}}
 +
* {{Tl|Start date}}
 +
 
 +
<includeonly>{{sandbox other||
 +
<!-- Categories below this line; interwikis at Wikidata -->
 +
[[Category:ISO date templates]]
 +
[[Category:Date conversion templates]]
 +
[[Category:Date-computing templates]]
 +
[[Category:Templates generating hAtom]]
 +
[[Category:Templates generating hCalendars]]
 +
[[Category:Templates generating hCards]]
 +
 
 +
}}</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-15

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