Difference between revisions of "Template:Date"

From Timelines
Jump to: navigation, search
m (Protected Template:Date: Highly visible template ([edit=sysop] (indefinite) [move=sysop] (indefinite)))
(update after exhaustive development at User:Fullstop/Sandbox/T1 and User:Happy-melon/sandbox1)
Line 1: Line 1:
 
<onlyinclude><!--
 
<onlyinclude><!--
 
+
-->{{#switch:none
< -- TEST IF DATE IS CORRUPT OR A FRAGMENT -- >
+
|{{#iferror: {{#time:Y_M_d|{{{1|}}} }}|none}}
-->{{#ifeq:{{#time:Y_M_d|{{{1|}}} 2037}} | {{#iferror: {{#time:Y_M_d|{{{1|}}} }} | *ERROR* }}
+
|{{#switch:{{lc:{{{2|}}}}}|none|asis=none}}
  |{{#ifeq: {{{3|}}}|y
+
|{{#ifexpr: {{#time:Y|{{{1|}}} }} < 1582|none}}<!--
   |{{#switch: {{{2|}}}
+
--> = {{{1|}}}<!-- error or "none", so no formatting -->
    | asis | none    = {{{1|}}}
+
  |<!-- continue with formatting -->
     | mdy            = [[{{ #time:F j|{{{1|}}} }}]], [[{{ #time:Y|{{{1|}}} }}]]
+
  {{#iferror: {{#expr:{{{1|dummy}}} }}
    | iso | ymd      = [[{{ #time:Y|{{{1|}}} }}]] [[{{ #time:F j|{{{1|}}} }}|{{ #time:m-d|{{{1|}}} }}]]
+
   |<!-- input is not just a solitary number -->
    | dmy | #default = [[{{ #time:j F|{{{1|}}} }}]] [[{{ #time:Y|{{{1|}}} }}]]
+
    {{#ifeq:{{#time:Y|{{{1|1 Jan 2000}}} 1996}}{{#time:Y|{{{1|1 Jan 2000}}} 2004}}|19962004
  }}
+
     |<!-- no year -->
  |{{#switch: {{{2|}}}
+
      {{#ifeq:{{#time:d|{{{1|}}} 2036}}|{{#time:d|{{{1|}}} }}
    | asis | none    = {{{1|}}}
+
      |<!-- month+day -->{{#time:
    | mdy           = {{ #time:F j, Y|{{{1|}}} }}  
+
        {{#switch: {{lc: {{#ifeq:{{{3|}}}|y|L}}{{{2|}}} }}
    | iso | ymd      = {{ #time:Y-m-d|{{{1|}}} }}
+
        | lmdy | liso | lymd      = [[:F j]]
    | dmy | #default = {{ #time:j F Y|{{{1|}}} }}
+
        | mdy  | iso  | ymd      = F j
  }}
+
        | ldmy | l                = [[:j F]]
   }}
+
        | #default                = j F
|{{{1|}}}
+
        }}|{{{1|}}} 2000 }}<!-- default='dmy' or null or "" or unsupported option -->
 +
      |<!-- month only -->{{#time:
 +
        {{#switch: {{lc: {{#ifeq:{{{3|}}}|y|L}}{{{2|}}} }}
 +
        | lmdy | liso | lymd
 +
        | ldmy | l                = [[F]]
 +
        | #default                = F
 +
        }}|{{{1|}}} 2000 }}<!-- default='dmy'/'mdy'/'ymd'/'iso'/null/""/unsupported opt -->
 +
      }}
 +
    |<!-- with year-->
 +
      {{#if: {{#iferror:{{#time:j|2 {{{1|}}}}}|*D*|{{#iferror:{{#time:j|2000 {{{1|}}}}}|*D*| }}}}
 +
      |<!-- day+month+year -->{{#time:
 +
        {{#switch: {{lc: {{#ifeq:{{{3|}}}|y|L}}{{{2|}}} }}
 +
        | lmdy                    = [[:F j]], [[Y]]
 +
        | mdy                     = F j, Y
 +
        | liso                    = [[Y|Y-]][[F j|m-d]]<!-- i.e. [[Y-m-d]] -->
 +
        | iso                    = Y-m-d
 +
        | lymd                    = [[Y]] [[:F j]]
 +
        | ymd                    = Y F j
 +
        | ldmy | l                = [[:j F]] [[Y]]
 +
        | #default                = j F Y
 +
        }}|{{{1|}}} }}<!-- #default='dmy' or null or "" or unsupported option -->
 +
      |<!-- month+year -->{{#time:
 +
        {{#switch: {{lc: {{#ifeq:{{{3|}}}|y|L}}{{{2|}}} }}
 +
        | lmdy | liso | lymd | ldmy | l  = [[:F Y]]
 +
        | #default               = F Y
 +
        }}|{{{1|}}} }}<!-- default='dmy'/'iso'/'mdy'/null/""/unsupported option -->
 +
      }}
 +
    }}
 +
   |<!-- input is a solitary number. Treat it as just a year. -->
 +
    {{#switch: {{lc: {{#ifeq:{{{3|}}}|y|L}}{{{2|}}} }}
 +
    | lmdy | liso | lymd
 +
    | ldmy | l                = [[{{#expr:{{{1|}}} }}]]
 +
    | #default                = {{#expr:{{{1|}}} }}
 +
    }}
 +
  }}   
 
}}</onlyinclude>
 
}}</onlyinclude>
{{documentation}}
 

Revision as of 08:49, 18 December 2008

18 December 2024