Template:MONTHNUMBER: Difference between revisions

Jump to navigation Jump to search
imported>Verdy p
mNo edit summary
imported>PineApple1298
m (1 revision imported)
 
(19 intermediate revisions by 10 users not shown)
Line 1: Line 1:
<includeonly>{{#if:{{{1|}}}|{{#ifexpr:{{{1|}}}<0|{{#ifexpr:(({{{1|}}})round 0)!=({{{1|}}})|{{#expr:
<includeonly>{{#if:{{{1|}}}
  12-(((0.5-({{{1|}}}))round 0)mod 12)
|{{#switch:{{lc:{{{1}}}}}
}}|{{#expr:
  |january|jan=1
  12-(((0.5-({{{1|}}}))round 0)mod 12)
  |february|feb=2
}}}}|{{#expr:(((10.5+{{{1|}}})round 0)mod 12)+1}}}}|Missing required parameter 1=''month''!}}</includeonly><noinclude>{{Template documentation}}
  |march|mar=3
This template returns the cyclic integer month number (between 1 and 12) of the month whose real number is in parameter.
  |apr|april=4
; Syntax<nowiki>:</nowiki>
  |may=5
: <tt><nowiki>{{</nowiki>MONTHNUMBER|</tt>''month''<tt>}}</tt>
  |june|jun=6
* The ''month'' value is interpreted modulo 12 (extra leading zeroes are ignored, negative numbers are accepted, all numbers are rounded to floor).
  |july|jul=7
 
  |august|aug=8
; Examples for all months<nowiki>:</nowiki>
  |september|sep|sept=9
: <tt><nowiki>{{MONTHNUMBER|1}}</nowiki></tt> returns {{MONTHNUMBER|1}}
  |october|oct=10
: <tt><nowiki>{{MONTHNUMBER|2}}</nowiki></tt> returns {{MONTHNUMBER|2}}
  |november|nov=11
: <tt><nowiki>{{MONTHNUMBER|3}}</nowiki></tt> returns {{MONTHNUMBER|3}}
  |december|dec=12
: <tt><nowiki>{{MONTHNUMBER|4}}</nowiki></tt> returns {{MONTHNUMBER|4}}
  |{{#ifexpr:{{{1}}}<0
: <tt><nowiki>{{MONTHNUMBER|5}}</nowiki></tt> returns {{MONTHNUMBER|5}}
  |{{#ifexpr:(({{{1}}})round 0)!=({{{1}}})
: <tt><nowiki>{{MONTHNUMBER|6}}</nowiki></tt> returns {{MONTHNUMBER|6}}
    |{{#expr:12-(((0.5-({{{1}}}))round 0)mod 12)}}
: <tt><nowiki>{{MONTHNUMBER|7}}</nowiki></tt> returns {{MONTHNUMBER|7}}
    |{{#expr:12-(((11.5-({{{1}}}))round 0)mod 12)}}
: <tt><nowiki>{{MONTHNUMBER|8}}</nowiki></tt> returns {{MONTHNUMBER|8}}
  }}
: <tt><nowiki>{{MONTHNUMBER|9}}</nowiki></tt> returns {{MONTHNUMBER|9}}
  |{{#expr:(((10.5+{{{1}}})round 0)mod 12)+1}}
: <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}}
|Missing required parameter 1=''month''!
 
}}</includeonly><noinclude>
; Examples for months with extra leading zero<nowiki>:</nowiki>
{{Documentation}}
: <tt><nowiki>{{MONTHNUMBER|01}}</nowiki></tt> returns {{MONTHNUMBER|01}}
<!-- Add categories and interwikis to the /doc subpage, not here! -->
: <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 underflow and overflow, from computed values<nowiki>:</nowiki>
: <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}}
 
; See also<nowiki>:</nowiki>
: [[Template:MONTHNAME]]
 
[[Category:Date computing template|MONTHNUMBER]]
 
[[fr:Modèle:MONTHNUMBER]]
</noinclude>
</noinclude>

Latest revision as of 21:07, 27 January 2021