Template:MONTHNUMBER: Difference between revisions

    From Nonbinary Wiki
    mNo edit summary
    m (22 revisions imported from wikipedia:Template:MONTHNUMBER)
     
    (13 intermediate revisions by 10 users not shown)
    Line 1: Line 1:
    <includeonly>{{#if:{{{1|}}}|{{#switch:{{lc:{{{1}}}}}|january|jan=1|february|feb=2|march|mar=3|apr|april=4|may=5|june|jun=6|july|jul=7|august|aug=8|september|sep=9|october|oct=10|november|nov=11|december|dec=12|{{#ifexpr:{{{1}}}<0|{{#ifexpr:(({{{1}}})round 0)!=({{{1}}})|{{#expr:12-(((0.5-({{{1}}}))round 0)mod 12)}}|{{#expr:12-(((11.5-({{{1}}}))round 0)mod 12)}}}}|{{#expr:(((10.5+{{{1}}})round 0)mod 12)+1}}}}}}|Missing required parameter 1=''month''!}}</includeonly><noinclude>{{Template documentation}}
    <includeonly>{{#if:{{{1|}}}
    This template returns the cyclic integer month number (between 1 and 12) of the month whose real number is in parameter. Alternatively, the month can be given with its english name (complete or abbreviated to 3 characters, with capitals or small letters).
    |{{#switch:{{lc:{{{1}}}}}
    ; Syntax<nowiki>:</nowiki>
      |january|jan=1
    : <tt><nowiki>{{</nowiki>MONTHNUMBER|</tt>''month''<tt>}}</tt>
      |february|feb=2
    * The ''month'' value is interpreted modulo 12 (extra leading zeroes are ignored, negative numbers are accepted, all numbers are rounded to floor).
      |march|mar=3
     
      |apr|april=4
    ; Examples for all standard English month names<nowiki>:</nowiki>
      |may=5
    : <tt><nowiki>{{MONTHNUMBER|january}}</nowiki></tt> returns {{MONTHNUMBER|january}}
      |june|jun=6
    : <tt><nowiki>{{MONTHNUMBER|february}}</nowiki></tt> returns {{MONTHNUMBER|february}}
      |july|jul=7
    : <tt><nowiki>{{MONTHNUMBER|march}}</nowiki></tt> returns {{MONTHNUMBER|march}}
      |august|aug=8
    : <tt><nowiki>{{MONTHNUMBER|april}}</nowiki></tt> returns {{MONTHNUMBER|april}}
      |september|sep|sept=9
    : <tt><nowiki>{{MONTHNUMBER|may}}</nowiki></tt> returns {{MONTHNUMBER|may}}
      |october|oct=10
    : <tt><nowiki>{{MONTHNUMBER|june}}</nowiki></tt> returns {{MONTHNUMBER|june}}
      |november|nov=11
    : <tt><nowiki>{{MONTHNUMBER|july}}</nowiki></tt> returns {{MONTHNUMBER|july}}
      |december|dec=12
    : <tt><nowiki>{{MONTHNUMBER|august}}</nowiki></tt> returns {{MONTHNUMBER|august}}
      |{{#ifexpr:{{{1}}}<0
    : <tt><nowiki>{{MONTHNUMBER|september}}</nowiki></tt> returns {{MONTHNUMBER|september}}
      |{{#ifexpr:(({{{1}}})round 0)!=({{{1}}})
    : <tt><nowiki>{{MONTHNUMBER|october}}</nowiki></tt> returns {{MONTHNUMBER|october}}
        |{{#expr:12-(((0.5-({{{1}}}))round 0)mod 12)}}
    : <tt><nowiki>{{MONTHNUMBER|november}}</nowiki></tt> returns {{MONTHNUMBER|november}}
        |{{#expr:12-(((11.5-({{{1}}}))round 0)mod 12)}}
    : <tt><nowiki>{{MONTHNUMBER|december}}</nowiki></tt> returns {{MONTHNUMBER|december}}
      }}
     
      |{{#expr:(((10.5+{{{1}}})round 0)mod 12)+1}}
    ; Examples for all abbreviated English month names<nowiki>:</nowiki>
      }}
    : <tt><nowiki>{{MONTHNUMBER|jan}}</nowiki></tt> returns {{MONTHNUMBER|jan}}
    }}
    : <tt><nowiki>{{MONTHNUMBER|feb}}</nowiki></tt> returns {{MONTHNUMBER|feb}}
    |Missing required parameter 1=''month''!
    : <tt><nowiki>{{MONTHNUMBER|mar}}</nowiki></tt> returns {{MONTHNUMBER|mar}}
    }}</includeonly><noinclude>
    : <tt><nowiki>{{MONTHNUMBER|apr}}</nowiki></tt> returns {{MONTHNUMBER|apr}}
    {{Documentation}}
    : <tt><nowiki>{{MONTHNUMBER|may}}</nowiki></tt> returns {{MONTHNUMBER|may}}
    <!-- Add categories and interwikis to the /doc subpage, not here! -->
    : <tt><nowiki>{{MONTHNUMBER|jun}}</nowiki></tt> returns {{MONTHNUMBER|jun}}
    : <tt><nowiki>{{MONTHNUMBER|jul}}</nowiki></tt> returns {{MONTHNUMBER|jul}}
    : <tt><nowiki>{{MONTHNUMBER|aug}}</nowiki></tt> returns {{MONTHNUMBER|aug}}
    : <tt><nowiki>{{MONTHNUMBER|sep}}</nowiki></tt> returns {{MONTHNUMBER|sep}}
    : <tt><nowiki>{{MONTHNUMBER|oct}}</nowiki></tt> returns {{MONTHNUMBER|oct}}
    : <tt><nowiki>{{MONTHNUMBER|nov}}</nowiki></tt> returns {{MONTHNUMBER|nov}}
    : <tt><nowiki>{{MONTHNUMBER|dec}}</nowiki></tt> returns {{MONTHNUMBER|dec}}
     
    ; Examples for all standard month numbers<nowiki>:</nowiki>
    : <tt><nowiki>{{MONTHNUMBER|1}}</nowiki></tt> returns {{MONTHNUMBER|1}}
    : <tt><nowiki>{{MONTHNUMBER|2}}</nowiki></tt> returns {{MONTHNUMBER|2}}
    : <tt><nowiki>{{MONTHNUMBER|3}}</nowiki></tt> returns {{MONTHNUMBER|3}}
    : <tt><nowiki>{{MONTHNUMBER|4}}</nowiki></tt> returns {{MONTHNUMBER|4}}
    : <tt><nowiki>{{MONTHNUMBER|5}}</nowiki></tt> returns {{MONTHNUMBER|5}}
    : <tt><nowiki>{{MONTHNUMBER|6}}</nowiki></tt> returns {{MONTHNUMBER|6}}
    : <tt><nowiki>{{MONTHNUMBER|7}}</nowiki></tt> returns {{MONTHNUMBER|7}}
    : <tt><nowiki>{{MONTHNUMBER|8}}</nowiki></tt> returns {{MONTHNUMBER|8}}
    : <tt><nowiki>{{MONTHNUMBER|9}}</nowiki></tt> returns {{MONTHNUMBER|9}}
    : <tt><nowiki>{{MONTHNUMBER|10}}</nowiki></tt> returns {{MONTHNUMBER|10}}
    : <tt><nowiki>{{MONTHNUMBER|11}}</nowiki></tt> returns {{MONTHNUMBER|11}}
    : <tt><nowiki>{{MONTHNUMBER|12}}</nowiki></tt> returns {{MONTHNUMBER|12}}
     
    ; Examples for month numbers with extra leading zero<nowiki>:</nowiki>
    : <tt><nowiki>{{MONTHNUMBER|01}}</nowiki></tt> returns {{MONTHNUMBER|01}}
    : <tt><nowiki>{{MONTHNUMBER|02}}</nowiki></tt> returns {{MONTHNUMBER|02}}
    : <tt><nowiki>{{MONTHNUMBER|03}}</nowiki></tt> returns {{MONTHNUMBER|03}}
    : <tt><nowiki>{{MONTHNUMBER|04}}</nowiki></tt> returns {{MONTHNUMBER|04}}
    : <tt><nowiki>{{MONTHNUMBER|05}}</nowiki></tt> returns {{MONTHNUMBER|05}}
    : <tt><nowiki>{{MONTHNUMBER|06}}</nowiki></tt> returns {{MONTHNUMBER|06}}
    : <tt><nowiki>{{MONTHNUMBER|07}}</nowiki></tt> returns {{MONTHNUMBER|07}}
    : <tt><nowiki>{{MONTHNUMBER|08}}</nowiki></tt> returns {{MONTHNUMBER|08}}
    : <tt><nowiki>{{MONTHNUMBER|09}}</nowiki></tt> returns {{MONTHNUMBER|09}}
     
    ; Examples for month number underflows and overflows, from computed values<nowiki>:</nowiki>
    : <tt><nowiki>{{MONTHNUMBER|-1200}}</nowiki></tt> returns {{MONTHNUMBER|-1200}}
    : <tt><nowiki>{{MONTHNUMBER|-1201}}</nowiki></tt> returns {{MONTHNUMBER|-1201}}
    : <tt><nowiki>{{MONTHNUMBER|-1212}}</nowiki></tt> returns {{MONTHNUMBER|-1212}}
    : <tt><nowiki>{{MONTHNUMBER|-12}}</nowiki></tt> returns {{MONTHNUMBER|-12}}
    : <tt><nowiki>{{MONTHNUMBER|-11}}</nowiki></tt> returns {{MONTHNUMBER|-11}}
    : <tt><nowiki>{{MONTHNUMBER|-10}}</nowiki></tt> returns {{MONTHNUMBER|-10}}
    : <tt><nowiki>{{MONTHNUMBER|-9}}</nowiki></tt> returns {{MONTHNUMBER|-9}}
    : <tt><nowiki>{{MONTHNUMBER|-8}}</nowiki></tt> returns {{MONTHNUMBER|-8}}
    : <tt><nowiki>{{MONTHNUMBER|-7}}</nowiki></tt> returns {{MONTHNUMBER|-7}}
    : <tt><nowiki>{{MONTHNUMBER|-6}}</nowiki></tt> returns {{MONTHNUMBER|-6}}
    : <tt><nowiki>{{MONTHNUMBER|-5}}</nowiki></tt> returns {{MONTHNUMBER|-5}}
    : <tt><nowiki>{{MONTHNUMBER|-4}}</nowiki></tt> returns {{MONTHNUMBER|-4}}
    : <tt><nowiki>{{MONTHNUMBER|-3}}</nowiki></tt> returns {{MONTHNUMBER|-3}}
    : <tt><nowiki>{{MONTHNUMBER|-2}}</nowiki></tt> returns {{MONTHNUMBER|-2}}
    : <tt><nowiki>{{MONTHNUMBER|-1}}</nowiki></tt> returns {{MONTHNUMBER|-1}}
    : <tt><nowiki>{{MONTHNUMBER|-0.9999}}</nowiki></tt> returns {{MONTHNUMBER|-0.9999}}
    : <tt><nowiki>{{MONTHNUMBER|-0.5}}</nowiki></tt> returns {{MONTHNUMBER|-0.5}}
    : <tt><nowiki>{{MONTHNUMBER|-0.0001}}</nowiki></tt> returns {{MONTHNUMBER|-0.0001}}
    : <tt><nowiki>{{MONTHNUMBER|0}}</nowiki></tt> returns {{MONTHNUMBER|0}}
    : <tt><nowiki>{{MONTHNUMBER|0.0001}}</nowiki></tt> returns {{MONTHNUMBER|0.0001}}
    : <tt><nowiki>{{MONTHNUMBER|0.5}}</nowiki></tt> returns {{MONTHNUMBER|0}}
    : <tt><nowiki>{{MONTHNUMBER|0.9999}}</nowiki></tt> returns {{MONTHNUMBER|0.9999}}
    : <tt><nowiki>{{MONTHNUMBER|12.0001}}</nowiki></tt> returns {{MONTHNUMBER|12.0001}}
    : <tt><nowiki>{{MONTHNUMBER|12.5}}</nowiki></tt> returns {{MONTHNUMBER|12.5}}
    : <tt><nowiki>{{MONTHNUMBER|12.9999}}</nowiki></tt> returns {{MONTHNUMBER|12.9999}}
    : <tt><nowiki>{{MONTHNUMBER|13}}</nowiki></tt> returns {{MONTHNUMBER|13}}
    : <tt><nowiki>{{MONTHNUMBER|14}}</nowiki></tt> returns {{MONTHNUMBER|14}}
    : <tt><nowiki>{{MONTHNUMBER|24}}</nowiki></tt> returns {{MONTHNUMBER|24}}
    : <tt><nowiki>{{MONTHNUMBER|1200}}</nowiki></tt> returns {{MONTHNUMBER|1200}}
    : <tt><nowiki>{{MONTHNUMBER|1201}}</nowiki></tt> returns {{MONTHNUMBER|1201}}
    : <tt><nowiki>{{MONTHNUMBER|1212}}</nowiki></tt> returns {{MONTHNUMBER|1212}}
     
    ; Example for invalid month name<nowiki>:</nowiki>
    : <tt><nowiki>{{MONTHNUMBER|xxx}}</nowiki></tt> returns {{MONTHNUMBER|xxx}}
     
    ; See also<nowiki>:</nowiki>
    : [[Template:MONTHNAME]]
    : [[Template:MONTHABBREV]]
     
    [[Category:Date computing template|MONTHNUMBER]]
     
    [[fr:Modèle:MONTHNUMBER]]
    </noinclude>
    </noinclude>

    Latest revision as of 11:59, 21 May 2021

    Template documentation[create]