Template:Start date: Difference between revisions

Created page with "<includeonly>{{#switch:{{#expr:{{{3|0}}} > 0}} | 1 = <!-- Y – M – D precision --> <time datetime="{{padleft:{{{1}}}|4|0}}-{{padleft:{{{2}}}|2|0}}-{{padleft:{{{3}}}|2|0}}"> {{#time:d F Y|{{{1}}}-{{{2}}}-{{{3}}}}} </time> | #default = <!-- Y – M precision --> <time datetime="{{padleft:{{{1}}}|4|0}}-{{padleft:{{{2}}}|2|0}}"> {{#time:F Y|{{{1}}}-{{{2}}}-01}} </time> }}</includeonly><noinclude> == Template documentation == ;Purpose :Formats a pu..."
 
No edit summary
Line 1: Line 1:
<includeonly>{{#switch:{{#expr:{{{3|0}}} > 0}}
<!-- =======================================================================
| 1 = <!-- Y – M – D precision -->
Template:Start date
  <time datetime="{{padleft:{{{1}}}|4|0}}-{{padleft:{{{2}}}|2|0}}-{{padleft:{{{3}}}|2|0}}">
Inline (no box) ISO-compatible date with micro-formatting for machine reading
    {{#time:d F Y|{{{1}}}-{{{2}}}-{{{3}}}}}
======================================================================= -->
  </time>
<includeonly>
| #default = <!-- Y – M precision -->
<span class="dtstart" title="{{#time:Y-m-d|{{{1}}}-{{{2|01}}}-{{{3|01}}}}}">
  <time datetime="{{padleft:{{{1}}}|4|0}}-{{padleft:{{{2}}}|2|0}}">
{{#time:F&nbsp;j, Y|{{{1}}}-{{{2|1}}}-{{{3|1}}}}}
    {{#time:F Y|{{{1}}}-{{{2}}}-01}}
</span>
  </time>
</includeonly><noinclude>
}}</includeonly><noinclude>
== Usage ==
<syntaxhighlight lang="text">
{{Start date|YYYY|MM|DD}}
</syntaxhighlight>
* '''YYYY''' – 4-digit year (required) 
* '''MM''' – 1- or 2-digit month (optional; defaults to 1) 
* '''DD''' – 1- or 2-digit day  (optional; defaults to 1)


== Template documentation ==
The template renders an **inline** date like “''April 21, 1994''” while the
;Purpose
`title` attribute supplies an ISO-8601 machine-readable form (`1994-04-21`)
:Formats a publication/release “start date” so that:
for Microformats (h-event → <span class="dtstart">).
* **Humans** see a friendly date (<code>12&nbsp;December&nbsp;1991</code> or <code>October&nbsp;1992</code>)
* **Machines/search engines** get an ISO-8601 timestamp via the HTML&nbsp;<code>&lt;time&gt;</code> element, improving metadata and accessibility.


;Syntax
=== Examples ===
<pre>{{Start date|year|month|day}}</pre>
; Specific day
 
:<code><nowiki>{{Start date|1991|11|21}}</nowiki></code> {{Start date|1991|11|21}}
;Parameters
; Month & year only
{| class="wikitable"
:<code><nowiki>{{Start date|1988|10}}</nowiki></code> {{Start date|1988|10}}
! # !! Name !! Mandatory !! Example !! Notes
; Year only
|-
:<code><nowiki>{{Start date|1978}}</nowiki></code> {{Start date|1978}}
| 1 || <code>year</code>  || Yes || 1991 || 4-digit year
|-
| 2 || <code>month</code> || Yes || 12 || 1–12 (leading zero optional)
|-
| 3 || <code>day</code>  || No  || 25 || 1–31. 
Omit for year-month precision.
|}
 
;Examples
{| class="wikitable"
! Wikitext !! Renders as
|-
| <code><nowiki>{{Start date|1991|12|12}}</nowiki></code> || {{Start date|1991|12|12}}
|-
| <code><nowiki>{{Start date|1992|10}}</nowiki></code>     || {{Start date|1992|10}}
|}
 
;Technical notes
* Uses <code>{{#switch:}}</code> to detect whether a day value was supplied.
* <code>{{padleft:…}}</code> zero-pads year/month/day to guarantee valid ISO format.
* <code>{{#time:}}</code> provides locale-aware formatting for the visible text.
* No hard-coded CSS; the skin controls styling of the generated <code>&lt;time&gt;</code> tag.


[[Category:Date formatting templates]]
</noinclude>
</noinclude>