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

From blackwiki
Jump to navigation Jump to search
imported>Trödel
(update documentation)
imported>Jonesey95
m (Fix Linter errors using AutoEd)
 
(18 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 formatted as DD MMMM YYYY and as MMMM DD, YYYY to the correct ISO format for use in tables that are expected to be sortable by date
 
=== 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.
 
  
Designed and used for [[Comparison of temples of The Church of Jesus Christ of Latter-day Saints]] until it can be generalized
+
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.
  
The template accepts one parameter - either named or unnamed. For example:
+
== 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
  
*{<nowiki>{</nowiki>ISO date|15 January 2001}} returns {{ISO date|15 January 2001}}  
+
* <code><nowiki>{{ISO date|Aug 17}}</nowiki></code> returns {{ISO date|Aug 17}}<br />
*{<nowiki>{</nowiki>ISO date|date = 10 January 2001}} returns {{ISO date|date = 10 January 2001}}  
+
* <code><nowiki>{{ISO date}}</nowiki></code> returns {{ISO date}}
  
=== See also ===
+
The template accepts one unnamed parameter containing a date in one of the following formats:
  
<includeonly>
+
* <code><nowiki>{{ISO date|15 January 2001}}</nowiki></code> returns {{ISO date|15 January 2001}}
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
+
* <code><nowiki>{{ISO date|15 Jan 2001}}</nowiki></code> returns {{ISO date|15 Jan 2001}}
[[Category:Date mathematics templates|ISO date]]
+
* <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}}
  
</includeonly>
+
* <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}}
 +
 
 +
* <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