Difference between revisions of "Template:Date"

From RobotX
Jump to navigation Jump to search
(Moved sandbox live to fix wrong output when substituted)
 
m (1 revision imported)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{{{{|safesubst:}}}#switch:none
+
<!-- 
|{{{{{|safesubst:}}}#iferror: {{{{{|safesubst:}}}#time:Y_M_d|{{{1|}}} }} | none }} <noinclude><!-- #time: can't handle --></noinclude>
+
{{{1|}}} = year: {{#expr: {{{1|}}} }} will strip leading zeros if any
|{{{{{|safesubst:}}}#iferror: {{{{{|safesubst:}}}#expr: {{{1|}}}+0 }}
+
{{{2|}}} = month: input to {{I18n month}}
    |<noinclude><!--not a pure number--></noinclude>
+
{{{3|}}} = day: {{#expr: {{{3}}} }} will strip leading zeros if any
    |{{{{{|safesubst:}}}#ifexpr: {{{1|}}}+0 > 10000000000000
+
{{{4|}}} = language code
      |<noinclude><!-- a yyyymmddhhmmss timestamp --></noinclude>
+
 
      |{{{{{|safesubst:}}}#ifeq: {{{{{|safesubst:}}}#expr:{{{1|}}}+0}} | {{{1|}}}
+
-->{{#if: {{{1|}}}{{{2|}}}{{{3|}}} |
          | none <noinclude><!-- pure number eg 123.456 --></noinclude>
+
{{#switch: {{#if: {{{4|}}} | {{{4}}} | {{pagelang2}} }}
          | <noinclude><!-- assume yy-mm-dd --></noinclude>
+
 
        }}
+
<!-- Spanish-like group (day de month de year) -->
    }}
+
|es |gl |pt
  }}
+
        ={{#if: {{{3|}}} | {{#expr: {{{3}}} }} de}} {{#if: {{{2|}}} | {{I18n month|{{{2|}}}|{{{4|}}}}} de }} {{{1|}}}
|{{{{{|safesubst:}}}#switch: {{{{{|safesubst:}}}lc:{{{2|}}}}} | none | asis | link | lnone =none }}
+
 
|{{{{{|safesubst:}}}#ifexpr:  {{{{{|safesubst:}}}#time:Y|{{{1|}}} }} < 1000 | none }}
+
<!-- Slavic group 1: if YYYY-MM-DD than month is in gen form, if YYYY-MM than month in basic form -->
|{{{{{|safesubst:}}}#switch: {{{{{|safesubst:}}}#time:Ynj|{{{1|}}} }}|100031|110031|130031|140031|150031=none}}
+
|uk |be |be-tarask |el
|= {{{{{|safesubst:}}}#if:{{{1|}}}
+
        ={{#if: {{{3|}}} | {{#expr:{{{3}}}}} {{I18n month|{{{2|}}}|{{{4|}}}|form=gen}} | {{I18n month|{{{2|}}}|{{{4|}}}}} }} {{{1|}}}
      |{{{{{|safesubst:}}}#switch:{{{2}}}
+
 
        |link|lnone|l=[[{{{1}}}]]
+
<!-- Slavic group 2: if YYYY-MM-DD than month is in gen form, if YYYY-MM than month form is controlled by {{{form}}} -->
        |{{{1}}}
+
|pl |ru ={{#if: {{{3|}}} | {{#expr:{{{3}}}}} {{I18n month|{{{2|}}}|{{{4|}}}|form=gen}} | {{I18n month|{{{2|}}}|{{{4|}}}|form={{{form|}}} }} }} {{{1|}}}
      }}
+
 
    }}<noinclude><!-- error or "none", so no formatting --></noinclude>
+
<!-- Finnish language: YYYY-MM-DD month in Partitive form, if YYYY-MM than month form is controlled by {{{form}}} -->
|<noinclude><!-- continue with formatting --></noinclude>
+
|fi      ={{#if: {{{3|}}} | {{#expr: {{{3}}} }}. {{I18n month|{{{2}}}|fi|form=ptv}} | {{I18n month|{{{2|}}}|fi|form={{{form|}}} }} }} {{{1|}}}
  {{{{{|safesubst:}}}#ifeq:<noinclude><!--
+
 
    --></noinclude>{{{{{|safesubst:}}}#time:Y|{{{1}}} 2008}}<noinclude><!--
+
<!-- German-like group (day. month year) -->
    --></noinclude>{{{{{|safesubst:}}}#iferror: {{{{{|safesubst:}}}#ifexpr: {{{1}}}>10000000000000 | no }} | }}<noinclude><!--
+
|da |de |de-formal |de-at |de-ch |bar |et |nds |nn |no
    --></noinclude>{{{{{|safesubst:}}}#time:Y|{{{1}}} 2004}}
+
        ={{#if: {{{3|}}} | {{#expr:{{{3}}}}}.}} {{I18n month|{{{2|}}}|{{{4|}}}}} {{{1|}}}
  |20082004
+
 
  |<noinclude><!-- no year --></noinclude>
+
<!-- South Asia group -->
    {{{{{|safesubst:}}}#ifeq:{{{{{|safesubst:}}}#time:d|{{{1}}} 2036}}|{{{{{|safesubst:}}}#time:d|{{{1}}} }}
+
|fa |hi |pa
    |<noinclude><!-- month+day --></noinclude>{{{{{|safesubst:}}}#time:
+
        ={{#if: {{{3|}}} | {{formatnum|{{#expr: {{{3}}} }}|{{{4|}}}|sep=1}} }} {{I18n month|{{{2|}}}|{{{4|}}}}} {{formatnum|{{{1|}}}|{{{4|}}}|sep=1}}
      {{{{{|safesubst:}}}#switch: {{{{{|safesubst:}}}lc: {{{{{|safesubst:}}}#ifeq:{{{3|}}}|y|L}}{{{2|}}} }}
+
 
      | lmdy | liso | lymd      = [[:F j]]
+
<!-- Chinese-like group (year年 month day日) -->
      | mdy  | iso  | ymd      = F j
+
|zh |zh-hans |zh-hant |zh-cn |zh-tw |ja
      | ldmy | l                = [[:j F]]
+
        ={{#if: {{{1|}}} | {{#expr:{{{1|}}}}}年}}{{I18n month|{{{2|}}}|{{{4|}}}}}{{#if: {{{3|}}} |{{#expr:{{{3|}}}}}日}}
      | #default                = j F
+
 
      }}|{{{1}}} 2000 }}<noinclude><!-- default='dmy' or null or "" or unsupported option --></noinclude>
+
<!-- individual languages in alphabetic order using syntax different than default or other groups below -->
    |<noinclude><!-- month only --></noinclude>{{{{{|safesubst:}}}#time:
+
|bn      ={{I18n month|{{{2|}}}|bn}} {{#if: {{{3|}}} | {{formatnum|{{#expr: {{{3}}} }}|bn|sep=1}} }}, {{formatnum|{{{1|}}}|bn|sep=1}}
      {{{{{|safesubst:}}}#switch: {{{{{|safesubst:}}}lc: {{{{{|safesubst:}}}#ifeq:{{{3|}}}|y|L}}{{{2|}}} }}
+
|bpy    ={{I18n month|{{{2|}}}|bpy}} {{#if: {{{3|}}} | {{formatnum|{{#expr: {{{3}}} }}|bpy|sep=1}} }}, মারি {{formatnum|{{{1|}}}|bpy|sep=1}}
      | lmdy | liso | lymd
+
|cs      ={{#if: {{{3|}}} | {{#expr: {{{3}}} }}. {{I18n month|{{{2|}}}|cs|form={{#if:{{{form|}}}|{{{form}}}|gen}}}} | {{I18n month|{{{2|}}}|cs|form={{{form|}}}}} }} {{{1|}}}
      | ldmy | l                = [[F]]
+
|eo      ={{#if: {{{3|}}} | la {{#expr: {{{3}}} }}-a de}} {{I18n month|{{{2|}}}|eo}} {{{1|}}}  
      | #default                = F
+
|fr      ={{#if: {{{3|}}} | {{#expr: {{{3}}}}}{{#ifeq: {{{3|}}} | 1 |<sup>er</sup>}} }} {{I18n month|{{{2|}}}|fr}} {{{1|}}}
      }}|{{{1}}} 2000 }}<noinclude><!-- default='dmy'/'mdy'/'ymd'/'iso'/null/""/unsupported opt --></noinclude>
+
|ga      ={{#if: {{{3|}}} | {{#expr: {{{3}}}}}{{#ifeq: {{{3|}}} | 1 |<sup>ú</sup>}} }} {{I18n month|{{{2|}}}|ga}} {{{1|}}}
    }}
+
|hr      ={{#if: {{{3|}}} | {{#expr: {{{3}}} }}.}} {{I18n month|{{{2|}}}|hr}} {{#if: {{{1|}}} | {{#expr: {{{1|}}} }}.}}
  |<noinclude><!-- with year--></noinclude>
+
|hu      ={{#if: {{{1|}}} | {{#expr: {{{1}}} }}.}} {{I18n month|{{{2|}}}|hu}} {{#if: {{{3|}}} | {{#expr: {{{3}}} }}{{#if: {{{form|}}} | | . }} }}
    {{{{{|safesubst:}}}#if: {{{{{|safesubst:}}}#iferror:{{{{{|safesubst:}}}#time:j|2 {{{1|}}}}}|*D*|{{{{{|safesubst:}}}#iferror:{{{{{|safesubst:}}}#time:j|2000 {{{1|}}}}}|*D*| }}}}
+
|ia      ={{#if: {{{3|}}} | {{#expr: {{{3}}} }} de}} {{#if: {{{2|}}} | {{I18n month|{{{2|}}}|ia}} }} {{{1|}}}
    |<noinclude><!-- day+month+year --></noinclude>{{{{{|safesubst:}}}#time:
+
|kn      ={{I18n month|{{{2|}}}|kn}} {{#if: {{{3|}}} | {{formatnum|{{#expr: {{{3}}} }}|kn|sep=1}} }}, {{formatnum|{{{1|}}}|kn|sep=1}}
      {{{{{|safesubst:}}}#switch: {{{{{|safesubst:}}}lc: {{{{{|safesubst:}}}#ifeq:{{{3|}}}|y|L}}{{{2|}}} }}
+
|ko      ={{#if: {{{1|}}} | {{#expr: {{{1|}}} }}년}} {{I18n month|{{{2|}}}|ko}} {{#if: {{{3|}}} |{{#expr:{{{3|}}}}}일}}
      | lmdy                    = [[:F j]], [[Y]]
+
|lt      ={{#if: {{{1|}}} | {{{1|}}} m. }} {{I18n month|{{{2|}}}|lt}} {{#if: {{{3|}}} | {{#expr: {{{3}}} }} d.}}
      | mdy                    = F j, Y
+
|lv      ={{#if: {{{1|}}} | {{#expr:{{{1|}}}}}. gada }} {{#if: {{{3|}}} | {{#expr: {{{3}}} }}.}} {{I18n month|{{{2|}}}|lv}}
      | liso                    = [[Y|Y-]][[F j|m-d]]<noinclude><!-- i.e. [[Y-m-d]] --></noinclude>
+
|mk      ={{#if: {{{3|}}} | {{#expr: {{{3}}} }} }} {{I18n month|{{{2|}}}|mk}} {{#expr: {{{1|}}} }}
      | iso                    = Y-m-d
+
|ml      ={{#if: {{{1|}}} | {{#expr:{{{3|}}} }}  {{I18n month|{{{2|}}}|ml}}  {{#expr:{{{1|}}} }}|{{I18n month|{{{2|}}}|ml}} {{#expr:{{{3|}}} }} }}
      | lymd                    = [[Y]] [[:F j]]
+
|mr      ={{I18n month|{{{2|}}}|mr}} {{#if: {{{3|}}} | {{formatnum|{{#expr: {{{3}}} }}|mr|sep=1}} }}, इ.स. {{formatnum|{{{1|}}}|mr|sep=1}}
      | ymd                    = Y F j
+
|new    ={{I18n month|{{{2|}}}|new}} {{#if: {{{3|}}} | {{formatnum|{{#expr: {{{3}}} }}|new|sep=1}} }}, ई सं {{formatnum|{{{1|}}}|new|sep=1}}
      | ldmy | l                = [[:j F]] [[Y]]
+
|oc      ={{#if: {{{3|}}} | {{#expr: {{{3}}} }} }} {{#if: {{{2|}}} | {{I18n month|{{{2|}}}|oc}} de }} {{{1|}}}
      | #default                = j F Y
+
|pt-br  ={{#if: {{{3|}}} | {{#expr: {{{3}}} }} de }} {{#if: {{{2|}}} | {{lc:{{I18n month|{{{2|}}}|pt}}}} de }} {{{1|}}}
      }}|{{{1|}}} }}<noinclude><!-- #default='dmy' or null or "" or unsupported option --></noinclude>
+
|sl      ={{#if: {{{3|}}} | {{#expr: {{{3}}} }}.}} {{I18n month|{{{2|}}}|sl|form={{{form|}}} }} {{{1|}}}
    |<noinclude><!-- month+year --></noinclude>{{{{{|safesubst:}}}#time:
+
|sr      ={{#if: {{{3|}}} | {{#expr: {{{3}}} }}.}} {{I18n month|{{{2|}}}|sr|}} {{#expr: {{{1|}}} }}.
      {{{{{|safesubst:}}}#switch: {{{{{|safesubst:}}}lc: {{{{{|safesubst:}}}#ifeq:{{{3|}}}|y|L}}{{{2|}}} }}
+
|th      ={{#if: {{{3|}}} | {{#expr: {{{3}}} }} }} {{I18n month|{{{2|}}}|th}} {{#if: {{{1|}}} | {{#ifexpr: {{{1}}} <= 1940 | {{#if: {{{2|}}} | {{#ifexpr: {{{2|}}} < 4 | พ.ศ. {{#expr: {{{1}}} + 542 }} | พ.ศ. {{#expr: {{{1}}} + 543 }} }} | {{#expr: {{{1}}} + 542 }} หรือ {{#expr: {{{1}}} + 543 }} }} | พ.ศ. {{#expr: {{{1}}} + 543 }} }} }}
      | lmdy | liso | lymd | ldmy | l  = [[:F Y]]
+
 
      | #default                = F Y
+
<!-- default (English) group (day month year) -->
      }}|{{{1|}}} }}<noinclude><!-- default='dmy'/'iso'/'mdy'/null/""/unsupported option --></noinclude>
+
|#default={{#expr:{{{3|}}}}} {{I18n month|{{{2|}}}|{{{4|}}}}} {{{1|}}}
    }}
+
 
  }}  
+
}}{{#if: {{{1|}}} |
}}<noinclude>
+
<span style="display:none">(<span class="dtstart">{{padleft:{{{1}}}|4|0}}{{#if: {{{2|}}}|-{{padleft:{{{2}}}|2|0}}}}{{#if: {{{3|}}}|-{{padleft:{{{3}}}|2|0}}}}</span>)</span>
{{documentation}}
+
}}}}<noinclude>
 +
{{documentation|content=
 +
 
 +
== Examples ==
 +
 
 +
<nowiki>{{date|2016|06|10}}</nowiki>
 +
{{date|2016|06|10}}
 +
 
 +
<nowiki>{{date|2016|06}}</nowiki>
 +
{{date|2016|06}}
 +
 
 +
<nowiki>{{date|2016|06|4=ja}}</nowiki>
 +
{{date|2016|06|4=ja}}
 +
 
 +
}}
 
</noinclude>
 
</noinclude>

Latest revision as of 03:17, 18 January 2020

Template documentation

Examples

{{date|2016|06|10}}

10 June 2016(2016-06-10)

{{date|2016|06}}

June 2016(2016-06)

{{date|2016|06|4=ja}}

2016年6月(2016-06)