Template:Start date and age/doc: Difference between revisions

(Since all is missing, I just added the minimal startup doc.)
 
m (156 revisions imported from wikipedia:Template:Start_date_and_age/doc)
 
(155 intermediate revisions by 68 users not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
{{high-use}}
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
<!-- Categories go at the bottom of this page and interwikis go in Wikidata. -->


The '''{{tl|Start date and age}}''' template displays the date that an event or entity started or was created. It also includes a duplicate, machine-readable date in the [[ISO 8601]] format (which is hidden by [[CSS]]), for use inside other templates which emit [[microformat]]s. The hidden date degrades gracefully when CSS is not available.
=== Usage ===


== Usage ==
<nowiki>{{Start date and age|YYYY|MM|DD}}</nowiki> will give ''DD Month YYYY; XX days ago''
;Common usage
: <code><nowiki>{{Start date and age|yyyy|mm|dd}}</nowiki></code> to display formatted as:
: {{xt|{{Start date and age|2010|03|25}}}}
: <code><nowiki>{{Start date and age|yyyy|mm|dd|df=yes}}</nowiki></code> to display formatted as:
: {{xt|{{Start date and age|2010|03|25|df=yes}}}}


;Full syntax
<!-- === See also === -->
: <code><nowiki>{{Start date and age|yyyy|mm|dd|df=yes|p=yes|br=yes}}</nowiki></code> to display formatted as:
: {{xt|{{Start date and age|2010|03|25|df=yes|p=yes|br=yes}}}}


== Parameters ==
<includeonly>
{| class="wikitable"
<!-- CATEGORIES AND INTERWIKIS BELOW THIS LINE PLEASE -->
! Parameter
! Status
! Description
|-
| 1
| required
| A four-digit number indicating the year.
|-
| 2
| optional
| A number between 1 and 12 indicating the month (leading zeros in the number are ignored). The month may also be specified as a name or abbreviation (e.g. "August" or "Aug").
|-
| 3
| optional
| A number between 1 and 31 indicating the day of the month (leading zeros in the number are ignored).
|-
| df=
| optional
| If the parameter '''df''' equals '''yes''', '''y''', or '''1''', the date will be displayed in DMY format: {{xt|4 March 2010}}. When this parameter is not included or set to some other value, the date will be displayed in MDY format: {{xt|March 4, 2010}}.
|-
| p=<br/>paren=
| optional
| If the parameter '''p''' or '''paren''' equals '''yes''', '''y''', or '''1''', the age will be displayed within parentheses. When this parameter is not included or set to some other value, the date and age are separated by a semicolon and a breaking space.
|-
| br=
| optional
| If the parameter '''br''' equals '''yes''', '''y''', or '''1''', a line break will be inserted between the date and the age. When this parameter is not included or set to some other value, a breaking space will be inserted between the date and the age. This does not change the separating characters between the date and age which are either a semicolon (default setting) or parentheses (if '''p=yes''').
|-
| end=
| optional
| This template includes hidden microformat {{tag|span|open|attribs=class="bday dtstart published updated"}}, similar to [[Template:Start date]]. If the parameter '''end''' equals '''yes''', '''y''', or '''1''', the template will instead use {{tag|span|open|attribs=class="dtend"}}, similar to [[Template:End date]]. This parameter is used by [[Template:End date and age]]. For more details, see [[Wikipedia:WikiProject Microformats]].
|}


==="df" (day first) and "mf" (month first)===
</includeonly>
The default output of this template is to display the month before the day (MDY). This default may not be appropriate for articles about events or entities in parts of the world where dates are commonly given with the day preceding the month (DMY). To display the day first, assign the '''df''' parameter a value of '''yes''', '''y''', or '''1''' (e.g. '''df=yes''').

If the default format is preferred, the parameter '''df''' may be used with value of '''no''', '''n''', or '''0''' (e.g. '''df=no'''). These values can assist [[WP:BOT|bots]] or other automated processing to detect the intended date format; omitting the '''df''' parameter may lead an editor or bot to change the format to an unintended value.

The preference to display the month first may also be indicated via the parameter '''mf''' (e.g. '''mf=yes'''). While not actually used by the template, this is another method of indicating that the default format is intended. Do not specify both "df" and "mf" parameters in the same use of the template.

== Examples ==
=== Default separator: semicolon ===
{| class="wikitable" style="width:100%;"
! style="width:60%;" | Syntax
! style="width:40%;" | Result
|-
|colspan="2" style="background-color:#DDD" | '''Full date (year, month, day)'''
|-
| {{tlx|Start date and age|<nowiki>2010|01|02</nowiki>}}
| {{Start date and age|2010|01|02}}
|-
| {{tlx|Start date and age|<nowiki>2008|Jan|09|df=no</nowiki>}}
| {{Start date and age|2008|Jan|09|df=no}}
|-
| {{tlx|Start date and age|<nowiki>2003|January|05|mf=yes</nowiki>}}
| {{Start date and age|2003|January|05|mf=yes}}
|-
| {{tlx|Start date and age|<nowiki>2010|1|2|df=yes</nowiki>}}
| {{Start date and age|2010|1|2|df=yes}}
|-
| {{tlx|Start date and age|<nowiki>2008|Jan|9|df=y</nowiki>}}
| {{Start date and age|2008|Jan|9|df=y}}
|-
| {{tlx|Start date and age|<nowiki>2003|January|5|df=1</nowiki>}}
| {{Start date and age|2003|January|5|df=1}}
|-
| 100 days ago:<br />{{tlx|Start date and age|{{#time:Y|now-100 days}}|{{#time:n|now-100 days}}|{{#time:j|now-100 days}}}}
| {{Start date and age|{{#time:Y|now-100 days}}|{{#time:n|now-100 days}}|{{#time:j|now-100 days}}}}
|-
| Yesterday:<br />{{tlx|Start date and age|{{#time:Y|now-1 days}}|{{#time:n|now-1 days}}|{{#time:j|now-1 days}}}}
| {{Start date and age|{{#time:Y|now-1 days}}|{{#time:n|now-1 days}}|{{#time:j|now-1 days}}}}
|-
| Today:<br />{{tlx|Start date and age|{{#time:Y|now}}|{{#time:n|now}}|{{#time:j|now}}}}
| {{Start date and age|{{#time:Y|now}}|{{#time:n|now}}|{{#time:j|now}}}}
|-
|colspan="2" style="background-color:#DDD" | '''Year and month'''
|-
| {{tlx|Start date and age|<nowiki>2001|9</nowiki>}}
| {{Start date and age|2001|9}}
|-
| {{tlx|Start date and age|<nowiki>2002|09</nowiki>}}
| {{Start date and age|2002|09}}
|-
| {{tlx|Start date and age|<nowiki>2003|Sep</nowiki>}}
| {{Start date and age|2003|Sep}}
|-
| {{tlx|Start date and age|<nowiki>2004|September</nowiki>}}
| {{Start date and age|2004|September}}
|-
|colspan="2" style="background-color:#DDD" | '''Year only'''
|-
| {{tlx|Start date and age|<nowiki>2005</nowiki>}}
| {{Start date and age|2005}}
|}

=== Optional separator: parentheses ===
{| class="wikitable" style="width:100%;"
! style="width:60%;" | Syntax
! style="width:40%;" | Result
|-
|colspan="2" style="background-color:#DDD" | '''Full date (year, month, day)'''
|-
| {{tlx|Start date and age|<nowiki>2003|02|15|p=yes</nowiki>}}
| {{Start date and age|2003|02|15|p=yes}}
|-
| {{tlx|Start date and age|<nowiki>2003|02|15|df=y|p=y</nowiki>}}
| {{Start date and age|2003|02|15|df=y|p=yes}}
|-
|colspan="2" style="background-color:#DDD" | '''Year and month'''
|-
| {{tlx|Start date and age|<nowiki>2003|02|p=1</nowiki>}}
| {{Start date and age|2003|02|p=1}}
|-
|colspan="2" style="background-color:#DDD" | '''Year only'''
|-
| {{tlx|Start date and age|<nowiki>2003|paren=yes</nowiki>}}
| {{Start date and age|2003|paren=yes}}
|}

=== Line break with semicolon ===
{| class="wikitable" style="width:100%;"
! style="width:60%;" | Syntax
! style="width:40%;" | Result
|-
|colspan="2" style="background-color:#DDD" | '''Full date (year, month, day)'''
|-
| {{tlx|Start date and age|<nowiki>2003|02|15|br=yes</nowiki>}}
| {{Start date and age|2003|02|15|br=yes}}
|-
| {{tlx|Start date and age|<nowiki>2003|02|15|df=y|br=y</nowiki>}}
| {{Start date and age|2003|02|15|df=y|br=y}}
|-
|colspan="2" style="background-color:#DDD" | '''Year and month'''
|-
| {{tlx|Start date and age|<nowiki>2003|02|br=1</nowiki>}}
| {{Start date and age|2003|02|br=1}}
|-
|colspan="2" style="background-color:#DDD" | '''Year only'''
|-
| {{tlx|Start date and age|<nowiki>2003|br=yes</nowiki>}}
| {{Start date and age|2003|br=yes}}
|}

=== Line break with parentheses ===
{| class="wikitable" style="width:100%;"
! style="width:60%;" | Syntax
! style="width:40%;" | Result
|-
|colspan="2" style="background-color:#DDD" | '''Full date (year, month, day)'''
|-
| {{tlx|Start date and age|<nowiki>2003|02|15|p=yes|br=yes</nowiki>}}
| {{Start date and age|2003|02|15|p=yes|br=yes}}
|-
| {{tlx|Start date and age|<nowiki>2003|02|15|df=y|p=y|br=y</nowiki>}}
| {{Start date and age|2003|02|15|df=y|p=y|br=y}}
|-
|colspan="2" style="background-color:#DDD" | '''Year and month'''
|-
| {{tlx|Start date and age|<nowiki>2003|02|p=1|br=1</nowiki>}}
| {{Start date and age|2003|02|p=1|br=1}}
|-
|colspan="2" style="background-color:#DDD" | '''Year only'''
|-
| {{tlx|Start date and age|<nowiki>2003|paren=yes|br=yes</nowiki>}}
| {{Start date and age|2003|paren=yes|br=yes}}
|}

== Use in microformats ==
{{UF-hcal-part}}

=== Example ===
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{Start date and age|2016|12|31}}</nowiki>}}

== Supporting templates ==
* [[Template:MONTHNAME]] – display name of month for a given number 1 (January) through 12 (December).
* [[Template:Time ago]] – display number of days, months, or years ago (for dates given as <code><nowiki>|yyyy|mm|dd</nowiki></code>).
* [[Template:Years or months ago]] – display number of months or years ago (for dates given as <code><nowiki>|yyyy|mm</nowiki></code> or <code><nowiki>|yyyy</nowiki></code>).
* [[Template:Yesno]] – allows optional formatting parameters to accept values other than "yes" (such as "y" or "1").

== See also ==
* {{tl|Start date}}
* {{tl|Time ago}} and {{tl|Years or months ago}}
* {{tl|Age}}

{{Birth, death and age templates |dates}}

==TemplateData ==
{{collapse top|[[Wikipedia:TemplateData|TemplateData]] documentation used by [[Wikipedia:VisualEditor|VisualEditor]] and other tools}}
{{TemplateData header|noheader=1}}
<templatedata>
{
"params": {
"1": {
"label": "Year",
"description": "A four-digit number indicating the year",
"example": "2017",
"type": "number",
"required": true
},
"2": {
"label": "Month",
"description": "A number between 1 and 12 indicating the month",
"example": "12",
"type": "number",
"suggested": true
},
"3": {
"label": "Day",
"description": "A number between 1 and 31 indicating the day of the month",
"example": "31",
"type": "number",
"suggested": true
},
"df": {
"label": "Display date first",
"description": "If the parameter df equals yes, y, or 1, the date will be displayed in DMY format: 4 March 2010. When this parameter is not included or set to some other value, the date will be displayed in MDY format: March 4, 2010.",
"example": "no",
"type": "boolean",
"default": "no"
},
"paren": {
"aliases": [
"p"
],
"label": "Display with parentheses",
"description": "If the parameter p or paren equals yes, y, or 1, the age will be displayed within parentheses. When this parameter is not included or set to some other value, the date and age are separated by a semicolon and a breaking space.",
"example": "yes",
"type": "boolean",
"default": "no"
},
"br": {
"label": "Line break between date and age",
"description": "If the parameter br equals yes, y, or 1, a line break will be inserted between the date and the age. When this parameter is not included or set to some other value, a breaking space will be inserted between the date and the age. This does not change the separating characters between the date and age which are either a semicolon (default setting) or parentheses (if paren=yes).",
"example": "yes",
"type": "boolean",
"default": "no"
},
"end": {
"label": "Use microformat for end date",
"description": "This template includes hidden microformat <span class=\"bday dtstart published updated\">, similar to Template:Start date. If the parameter end equals yes, y, or 1, the template will instead use <span class=\"dtend\">, similar to Template:End date. This parameter is used by Template:End date and age. For more details, see Wikipedia:WikiProject Microformats.",
"example": "yes",
"type": "boolean",
"default": "no"
}
},
"description": "The Start date and age template displays the date that an event or entity started or was created."
}
</templatedata>
{{collapse bottom}}

<includeonly>{{Sandbox other|
| <!-- Categories go here and interwikis go in Wikidata -->
[[Category:Date-computing templates based on current time]]
}}</includeonly>

Latest revision as of 23:23, 7 June 2021

The {{Start date and age}} template displays the date that an event or entity started or was created. It also includes a duplicate, machine-readable date in the ISO 8601 format (which is hidden by CSS), for use inside other templates which emit microformats. The hidden date degrades gracefully when CSS is not available.

Usage Edit

Common usage
{{Start date and age|yyyy|mm|dd}} to display formatted as:
March 25, 2010; 14 years ago (2010-03-25)
{{Start date and age|yyyy|mm|dd|df=yes}} to display formatted as:
25 March 2010; 14 years ago (2010-03-25)
Full syntax
{{Start date and age|yyyy|mm|dd|df=yes|p=yes|br=yes}} to display formatted as:
25 March 2010
(14 years ago)
 (2010-03-25)

Parameters Edit

Parameter Status Description
1 required A four-digit number indicating the year.
2 optional A number between 1 and 12 indicating the month (leading zeros in the number are ignored). The month may also be specified as a name or abbreviation (e.g. "August" or "Aug").
3 optional A number between 1 and 31 indicating the day of the month (leading zeros in the number are ignored).
df= optional If the parameter df equals yes, y, or 1, the date will be displayed in DMY format: 4 March 2010. When this parameter is not included or set to some other value, the date will be displayed in MDY format: March 4, 2010.
p=
paren=
optional If the parameter p or paren equals yes, y, or 1, the age will be displayed within parentheses. When this parameter is not included or set to some other value, the date and age are separated by a semicolon and a breaking space.
br= optional If the parameter br equals yes, y, or 1, a line break will be inserted between the date and the age. When this parameter is not included or set to some other value, a breaking space will be inserted between the date and the age. This does not change the separating characters between the date and age which are either a semicolon (default setting) or parentheses (if p=yes).
end= optional This template includes hidden microformat <span class="bday dtstart published updated">, similar to Template:Start date. If the parameter end equals yes, y, or 1, the template will instead use <span class="dtend">, similar to Template:End date. This parameter is used by Template:End date and age. For more details, see Wikipedia:WikiProject Microformats.

"df" (day first) and "mf" (month first) Edit

The default output of this template is to display the month before the day (MDY). This default may not be appropriate for articles about events or entities in parts of the world where dates are commonly given with the day preceding the month (DMY). To display the day first, assign the df parameter a value of yes, y, or 1 (e.g. df=yes).

If the default format is preferred, the parameter df may be used with value of no, n, or 0 (e.g. df=no). These values can assist bots or other automated processing to detect the intended date format; omitting the df parameter may lead an editor or bot to change the format to an unintended value.

The preference to display the month first may also be indicated via the parameter mf (e.g. mf=yes). While not actually used by the template, this is another method of indicating that the default format is intended. Do not specify both "df" and "mf" parameters in the same use of the template.

Examples Edit

Default separator: semicolon Edit

Syntax Result
Full date (year, month, day)
{{Start date and age|2010|01|02}} January 2, 2010; 14 years ago (2010-01-02)
{{Start date and age|2008|Jan|09|df=no}} January 9, 2008; 16 years ago (2008-01-09)
{{Start date and age|2003|January|05|mf=yes}} January 5, 2003; 21 years ago (2003-01-05)
{{Start date and age|2010|1|2|df=yes}} 2 January 2010; 14 years ago (2010-01-02)
{{Start date and age|2008|Jan|9|df=y}} 9 January 2008; 16 years ago (2008-01-09)
{{Start date and age|2003|January|5|df=1}} 5 January 2003; 21 years ago (2003-01-05)
100 days ago:
{{Start date and age|2024|2|9}}
February 9, 2024; 3 months ago (2024-02-09)
Yesterday:
{{Start date and age|2024|5|18}}
May 18, 2024; 1 day ago (2024-05-18)
Today:
{{Start date and age|2024|5|19}}
May 19, 2024; 0 days ago (2024-05-19)
Year and month
{{Start date and age|2001|9}} September 2001; 22 years ago (2001-09)
{{Start date and age|2002|09}} September 2002; 21 years ago (2002-09)
{{Start date and age|2003|Sep}} September 2003; 20 years ago (2003-09)
{{Start date and age|2004|September}} September 2004; 19 years ago (2004-09)
Year only
{{Start date and age|2005}} 2005; 19 years ago (2005)

Optional separator: parentheses Edit

Syntax Result
Full date (year, month, day)
{{Start date and age|2003|02|15|p=yes}} February 15, 2003 (21 years ago) (2003-02-15)
{{Start date and age|2003|02|15|df=y|p=y}} 15 February 2003 (21 years ago) (2003-02-15)
Year and month
{{Start date and age|2003|02|p=1}} February 2003 (21 years ago) (2003-02)
Year only
{{Start date and age|2003|paren=yes}} 2003 (21 years ago) (2003)

Line break with semicolon Edit

Syntax Result
Full date (year, month, day)
{{Start date and age|2003|02|15|br=yes}} February 15, 2003;
21 years ago
 (2003-02-15)
{{Start date and age|2003|02|15|df=y|br=y}} 15 February 2003;
21 years ago
 (2003-02-15)
Year and month
{{Start date and age|2003|02|br=1}} February 2003;
21 years ago
 (2003-02)
Year only
{{Start date and age|2003|br=yes}} 2003;
21 years ago
 (2003)

Line break with parentheses Edit

Syntax Result
Full date (year, month, day)
{{Start date and age|2003|02|15|p=yes|br=yes}} February 15, 2003
(21 years ago)
 (2003-02-15)
{{Start date and age|2003|02|15|df=y|p=y|br=y}} 15 February 2003
(21 years ago)
 (2003-02-15)
Year and month
{{Start date and age|2003|02|p=1|br=1}} February 2003
(21 years ago)
 (2003-02)
Year only
{{Start date and age|2003|paren=yes|br=yes}} 2003
(21 years ago)
 (2003)

Use in microformats Edit

This template also returns the date, hidden by CSS, in the ISO 8601 format needed by one or more of the following microformats:

usually, but not always, within infobox or similar templates, or tables.

Its use in hCard is for organizations, venues and similar; use {{Birth date}} or {{Birth date and age}} for people.

Similarly, {{End date}} returns the date as hCalendar's (class="dtend").

See the microformats project for further details.

Limitation Edit

This template has no provision to deal with a date in a non-Gregorian calendar. Also, ISO 8601 requires mutual agreement among those exchanging information before using years outside the range 1583–9999 CE. Therefore, use of this template for non-Gregorian dates or dates outside that range constitutes a false claim of conformance to the ISO 8601 standard.

Any editor encountering such usage should change the date to plain text with no template; or if not confident in doing so, raise the matter on this template's talk page.

Example Edit

  • {{Start date and age|2016|12|31}} → December 31, 2016; 7 years ago (2016-12-31)
    December&nbsp;31, 2016<span class="noprint">&#059;&#032;7 years ago</span><span style="display:none">&#160;(<span class="bday dtstart published updated">2016-12-31</span>)</span>

Supporting templates Edit

  • Template:MONTHNAME – display name of month for a given number 1 (January) through 12 (December).
  • Template:Time ago – display number of days, months, or years ago (for dates given as |yyyy|mm|dd).
  • Template:Years or months ago – display number of months or years ago (for dates given as |yyyy|mm or |yyyy).
  • Template:Yesno – allows optional formatting parameters to accept values other than "yes" (such as "y" or "1").

See also Edit

TemplateData Edit

TemplateData documentation used by VisualEditor and other tools
Click here to see a monthly parameter usage report for this template based on this TemplateData.

TemplateData for Start date and age

The Start date and age template displays the date that an event or entity started or was created.

Template parameters

ParameterDescriptionTypeStatus
Year1

A four-digit number indicating the year

Example
2017
Numberrequired
Month2

A number between 1 and 12 indicating the month

Example
12
Numbersuggested
Day3

A number between 1 and 31 indicating the day of the month

Example
31
Numbersuggested
Display date firstdf

If the parameter df equals yes, y, or 1, the date will be displayed in DMY format: 4 March 2010. When this parameter is not included or set to some other value, the date will be displayed in MDY format: March 4, 2010.

Default
no
Example
no
Booleanoptional
Display with parenthesesparen p

If the parameter p or paren equals yes, y, or 1, the age will be displayed within parentheses. When this parameter is not included or set to some other value, the date and age are separated by a semicolon and a breaking space.

Default
no
Example
yes
Booleanoptional
Line break between date and agebr

If the parameter br equals yes, y, or 1, a line break will be inserted between the date and the age. When this parameter is not included or set to some other value, a breaking space will be inserted between the date and the age. This does not change the separating characters between the date and age which are either a semicolon (default setting) or parentheses (if paren=yes).

Default
no
Example
yes
Booleanoptional
Use microformat for end dateend

This template includes hidden microformat <span class="bday dtstart published updated">, similar to Template:Start date. If the parameter end equals yes, y, or 1, the template will instead use <span class="dtend">, similar to Template:End date. This parameter is used by Template:End date and age. For more details, see Wikipedia:WikiProject Microformats.

Default
no
Example
yes
Booleanoptional