Jump to content

Template:Start date: Difference between revisions

From RetroTechCollection
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
ย 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly>{{#switch:{{#expr:{{{3|0}}} > 0}}
<!-- =========================================================
| 1 = <!-- Y โ€“ M โ€“ D precision -->
ย  ย  Template:Start dateย  โ€”ย  returns an inline, non-wrapping
ย  <time datetime="{{padleft:{{{1}}}|4|0}}-{{padleft:{{{2}}}|2|0}}-{{padleft:{{{3}}}|2|0}}">
ย  ย  โ€œMonth day, Yearโ€ string (e.g. โ€œDecember 12, 1991โ€)
ย  ย  {{#time:d F Y|{{{1}}}-{{{2}}}-{{{3}}}}}
============================================================= -->
ย  </time>
<includeonly><span class="nowrap">{{#time:F j, Y|{{{1}}}-{{{2|1}}}-{{{3|1}}}}}</span></includeonly><noinclude>
| #default = <!-- Y โ€“ M precision -->
== Usage ==
ย  <time datetime="{{padleft:{{{1}}}|4|0}}-{{padleft:{{{2}}}|2|0}}">
* `{{Start date|1991|12|12}}` โ†’ '''December 12, 1991'''
ย  ย  {{#time:F Y|{{{1}}}-{{{2}}}-01}}
* `{{Start date|1992|10|15}}` โ†’ '''October 15, 1992'''
ย  </time>
* You may omit the day or month: `{{Start date|1993|05}}` โ†’ '''May 1993'''
}}</includeonly><noinclude>


== Template documentation ==
The template purposely contains **no leading / trailing spaces** or newlines so it can be
;Purpose
embedded inside tables (e.g. infobox cells) without triggering unwanted
:Formats a publication/release โ€œstart dateโ€ so that:
paragraph (`<p>`) or preformatted (`<pre>`) blocks.
* **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
<pre>{{Start date|year|month|day}}</pre>
ย 
;Parameters
{| class="wikitable"
! # !! Name !! Mandatory !! Example !! Notes
|-
| 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.


The `nowrap` class (MediaWiki core) keeps the entire date on a single
line, avoiding ugly breaks inside infoboxes.ย 
</noinclude>
</noinclude>

Latest revision as of 12:17, 27 April 2025


  • `

December 12, 1991` โ†’ December 12, 1991

  • `

October 15, 1992` โ†’ October 15, 1992

  • You may omit the day or month: `

May 1, 1993` โ†’ May 1993

The template purposely contains **no leading / trailing spaces** or newlines so it can be embedded inside tables (e.g. infobox cells) without triggering unwanted

paragraph (`

`) or preformatted (`

`) blocks.

The `nowrap` class (MediaWiki core) keeps the entire date on a single
line, avoiding ugly breaks inside infoboxes.