Template:MONTHNUMBER: Difference between revisions
Jump to navigation
Jump to search
imported>Verdy p mNo edit summary |
imported>Verdy p mNo edit summary |
||
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|}}}|{{#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}} | ||
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). | 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). | ||
; Syntax<nowiki>:</nowiki> | ; Syntax<nowiki>:</nowiki> | ||
: <tt><nowiki>{{</nowiki>MONTHNUMBER|</tt>''month''<tt>}}</tt> | : <tt><nowiki>{{</nowiki>MONTHNUMBER|</tt>''month''<tt>}}</tt> | ||
Line 6: | Line 8: | ||
; Examples for all standard English month names<nowiki>:</nowiki> | ; Examples for all standard English month names<nowiki>:</nowiki> | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|january}}</nowiki></tt> returns {{{{PAGENAME}}|january}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|february}}</nowiki></tt> returns {{{{PAGENAME}}|february}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|march}}</nowiki></tt> returns {{{{PAGENAME}}|march}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|april}}</nowiki></tt> returns {{{{PAGENAME}}|april}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|may}}</nowiki></tt> returns {{{{PAGENAME}}|may}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|june}}</nowiki></tt> returns {{{{PAGENAME}}|june}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|july}}</nowiki></tt> returns {{{{PAGENAME}}|july}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|august}}</nowiki></tt> returns {{{{PAGENAME}}|august}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|september}}</nowiki></tt> returns {{{{PAGENAME}}|september}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|october}}</nowiki></tt> returns {{{{PAGENAME}}|october}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|november}}</nowiki></tt> returns {{{{PAGENAME}}|november}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|december}}</nowiki></tt> returns {{{{PAGENAME}}|december}} | ||
; Examples for all abbreviated English month names<nowiki>:</nowiki> | ; Examples for all abbreviated English month names<nowiki>:</nowiki> | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|jan}}</nowiki></tt> returns {{{{PAGENAME}}|jan}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|feb}}</nowiki></tt> returns {{{{PAGENAME}}|feb}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|mar}}</nowiki></tt> returns {{{{PAGENAME}}|mar}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|apr}}</nowiki></tt> returns {{{{PAGENAME}}|apr}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|may}}</nowiki></tt> returns {{{{PAGENAME}}|may}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|jun}}</nowiki></tt> returns {{{{PAGENAME}}|jun}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|jul}}</nowiki></tt> returns {{{{PAGENAME}}|jul}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|aug}}</nowiki></tt> returns {{{{PAGENAME}}|aug}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|sep}}</nowiki></tt> returns {{{{PAGENAME}}|sep}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|oct}}</nowiki></tt> returns {{{{PAGENAME}}|oct}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|nov}}</nowiki></tt> returns {{{{PAGENAME}}|nov}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|dec}}</nowiki></tt> returns {{{{PAGENAME}}|dec}} | ||
; Examples for all standard month numbers<nowiki>:</nowiki> | ; Examples for all standard month numbers<nowiki>:</nowiki> | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|1}}</nowiki></tt> returns {{{{PAGENAME}}|1}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|2}}</nowiki></tt> returns {{{{PAGENAME}}|2}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|3}}</nowiki></tt> returns {{{{PAGENAME}}|3}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|4}}</nowiki></tt> returns {{{{PAGENAME}}|4}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|5}}</nowiki></tt> returns {{{{PAGENAME}}|5}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|6}}</nowiki></tt> returns {{{{PAGENAME}}|6}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|7}}</nowiki></tt> returns {{{{PAGENAME}}|7}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|8}}</nowiki></tt> returns {{{{PAGENAME}}|8}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|9}}</nowiki></tt> returns {{{{PAGENAME}}|9}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|10}}</nowiki></tt> returns {{{{PAGENAME}}|10}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|11}}</nowiki></tt> returns {{{{PAGENAME}}|11}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|12}}</nowiki></tt> returns {{{{PAGENAME}}|12}} | ||
; Examples for month numbers with extra leading zero<nowiki>:</nowiki> | ; Examples for month numbers with extra leading zero<nowiki>:</nowiki> | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|01}}</nowiki></tt> returns {{{{PAGENAME}}|01}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|02}}</nowiki></tt> returns {{{{PAGENAME}}|02}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|03}}</nowiki></tt> returns {{{{PAGENAME}}|03}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|04}}</nowiki></tt> returns {{{{PAGENAME}}|04}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|05}}</nowiki></tt> returns {{{{PAGENAME}}|05}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|06}}</nowiki></tt> returns {{{{PAGENAME}}|06}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|07}}</nowiki></tt> returns {{{{PAGENAME}}|07}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|08}}</nowiki></tt> returns {{{{PAGENAME}}|08}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|09}}</nowiki></tt> returns {{{{PAGENAME}}|09}} | ||
; Examples for month number underflows and overflows, from computed values<nowiki>:</nowiki> | ; Examples for month number underflows and overflows, from computed values<nowiki>:</nowiki> | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-1200}}</nowiki></tt> returns {{{{PAGENAME}}|-1200}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-1201}}</nowiki></tt> returns {{{{PAGENAME}}|-1201}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-1212}}</nowiki></tt> returns {{{{PAGENAME}}|-1212}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-12}}</nowiki></tt> returns {{{{PAGENAME}}|-12}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-11}}</nowiki></tt> returns {{{{PAGENAME}}|-11}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-10}}</nowiki></tt> returns {{{{PAGENAME}}|-10}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-9}}</nowiki></tt> returns {{{{PAGENAME}}|-9}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-8}}</nowiki></tt> returns {{{{PAGENAME}}|-8}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-7}}</nowiki></tt> returns {{{{PAGENAME}}|-7}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-6}}</nowiki></tt> returns {{{{PAGENAME}}|-6}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-5}}</nowiki></tt> returns {{{{PAGENAME}}|-5}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-4}}</nowiki></tt> returns {{{{PAGENAME}}|-4}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-3}}</nowiki></tt> returns {{{{PAGENAME}}|-3}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-2}}</nowiki></tt> returns {{{{PAGENAME}}|-2}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-1}}</nowiki></tt> returns {{{{PAGENAME}}|-1}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-0.9999}}</nowiki></tt> returns {{{{PAGENAME}}|-0.9999}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-0.5}}</nowiki></tt> returns {{{{PAGENAME}}|-0.5}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-0.0001}}</nowiki></tt> returns {{{{PAGENAME}}|-0.0001}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|0}}</nowiki></tt> returns {{{{PAGENAME}}|0}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|0.0001}}</nowiki></tt> returns {{{{PAGENAME}}|0.0001}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|0.5}}</nowiki></tt> returns {{{{PAGENAME}}|0}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|0.9999}}</nowiki></tt> returns {{{{PAGENAME}}|0.9999}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|12.0001}}</nowiki></tt> returns {{{{PAGENAME}}|12.0001}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|12.5}}</nowiki></tt> returns {{{{PAGENAME}}|12.5}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|12.9999}}</nowiki></tt> returns {{{{PAGENAME}}|12.9999}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|13}}</nowiki></tt> returns {{{{PAGENAME}}|13}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|14}}</nowiki></tt> returns {{{{PAGENAME}}|14}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|24}}</nowiki></tt> returns {{{{PAGENAME}}|24}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|1200}}</nowiki></tt> returns {{{{PAGENAME}}|1200}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|1201}}</nowiki></tt> returns {{{{PAGENAME}}|1201}} | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|1212}}</nowiki></tt> returns {{{{PAGENAME}}|1212}} | ||
; Example for invalid month name<nowiki>:</nowiki> | ; Example for invalid month name<nowiki>:</nowiki> | ||
: <tt><nowiki>{{ | : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|xxx}}</nowiki></tt> returns {{{{PAGENAME}}|xxx}} | ||
; See also<nowiki>:</nowiki> | ; See also<nowiki>:</nowiki> |
Revision as of 21:24, 7 May 2006
Template:Template documentation
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).
- Syntax:
- {{MONTHNUMBER|month}}
- The month value is interpreted modulo 12 (extra leading zeroes are ignored, negative numbers are accepted, all numbers are rounded to floor).
- Examples for all standard English month names:
- {{MONTHNUMBER|january}} returns 1
- {{MONTHNUMBER|february}} returns 2
- {{MONTHNUMBER|march}} returns 3
- {{MONTHNUMBER|april}} returns 4
- {{MONTHNUMBER|may}} returns 5
- {{MONTHNUMBER|june}} returns 6
- {{MONTHNUMBER|july}} returns 7
- {{MONTHNUMBER|august}} returns 8
- {{MONTHNUMBER|september}} returns 9
- {{MONTHNUMBER|october}} returns 10
- {{MONTHNUMBER|november}} returns 11
- {{MONTHNUMBER|december}} returns 12
- Examples for all abbreviated English month names:
- {{MONTHNUMBER|jan}} returns 1
- {{MONTHNUMBER|feb}} returns 2
- {{MONTHNUMBER|mar}} returns 3
- {{MONTHNUMBER|apr}} returns 4
- {{MONTHNUMBER|may}} returns 5
- {{MONTHNUMBER|jun}} returns 6
- {{MONTHNUMBER|jul}} returns 7
- {{MONTHNUMBER|aug}} returns 8
- {{MONTHNUMBER|sep}} returns 9
- {{MONTHNUMBER|oct}} returns 10
- {{MONTHNUMBER|nov}} returns 11
- {{MONTHNUMBER|dec}} returns 12
- Examples for all standard month numbers:
- {{MONTHNUMBER|1}} returns 1
- {{MONTHNUMBER|2}} returns 2
- {{MONTHNUMBER|3}} returns 3
- {{MONTHNUMBER|4}} returns 4
- {{MONTHNUMBER|5}} returns 5
- {{MONTHNUMBER|6}} returns 6
- {{MONTHNUMBER|7}} returns 7
- {{MONTHNUMBER|8}} returns 8
- {{MONTHNUMBER|9}} returns 9
- {{MONTHNUMBER|10}} returns 10
- {{MONTHNUMBER|11}} returns 11
- {{MONTHNUMBER|12}} returns 12
- Examples for month numbers with extra leading zero:
- {{MONTHNUMBER|01}} returns 1
- {{MONTHNUMBER|02}} returns 2
- {{MONTHNUMBER|03}} returns 3
- {{MONTHNUMBER|04}} returns 4
- {{MONTHNUMBER|05}} returns 5
- {{MONTHNUMBER|06}} returns 6
- {{MONTHNUMBER|07}} returns 7
- {{MONTHNUMBER|08}} returns 8
- {{MONTHNUMBER|09}} returns 9
- Examples for month number underflows and overflows, from computed values:
- {{MONTHNUMBER|-1200}} returns 12
- {{MONTHNUMBER|-1201}} returns 11
- {{MONTHNUMBER|-1212}} returns 12
- {{MONTHNUMBER|-12}} returns 12
- {{MONTHNUMBER|-11}} returns 1
- {{MONTHNUMBER|-10}} returns 2
- {{MONTHNUMBER|-9}} returns 3
- {{MONTHNUMBER|-8}} returns 4
- {{MONTHNUMBER|-7}} returns 5
- {{MONTHNUMBER|-6}} returns 6
- {{MONTHNUMBER|-5}} returns 7
- {{MONTHNUMBER|-4}} returns 8
- {{MONTHNUMBER|-3}} returns 9
- {{MONTHNUMBER|-2}} returns 10
- {{MONTHNUMBER|-1}} returns 11
- {{MONTHNUMBER|-0.9999}} returns 11
- {{MONTHNUMBER|-0.5}} returns 11
- {{MONTHNUMBER|-0.0001}} returns 11
- {{MONTHNUMBER|0}} returns 12
- {{MONTHNUMBER|0.0001}} returns 12
- {{MONTHNUMBER|0.5}} returns 12
- {{MONTHNUMBER|0.9999}} returns 12
- {{MONTHNUMBER|12.0001}} returns 12
- {{MONTHNUMBER|12.5}} returns 12
- {{MONTHNUMBER|12.9999}} returns 12
- {{MONTHNUMBER|13}} returns 1
- {{MONTHNUMBER|14}} returns 2
- {{MONTHNUMBER|24}} returns 12
- {{MONTHNUMBER|1200}} returns 12
- {{MONTHNUMBER|1201}} returns 1
- {{MONTHNUMBER|1212}} returns 12
- Example for invalid month name:
- {{MONTHNUMBER|xxx}} returns Expression error: Unrecognized word "xxx".