Template:MONTHNUMBER

From Len'en Wiki
Jump to navigation Jump to search
Documentation icon Template documentation[view] [edit] [history] [purge]

{{MONTHNUMBER}} 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).

Does not play nicely with "subst:".

Syntax[edit source]

{{MONTHNUMBER|month}}
  • The month parameter is a value between 1 and 12 (extra leading zeroes are ignored, negative numbers are accepted, all numbers are rounded to floor). It can also accept English names "january" to "december", as well as abbreviations "jan" to "dec".

Examples for all standard English month names[edit source]

{{MONTHNUMBER<nowiki>|january}} returns 1
{{MONTHNUMBER<nowiki>|february}} returns 2
{{MONTHNUMBER<nowiki>|march}} returns 3
{{MONTHNUMBER<nowiki>|april}} returns 4
{{MONTHNUMBER<nowiki>|may}} returns 5
{{MONTHNUMBER<nowiki>|june}} returns 6
{{MONTHNUMBER<nowiki>|july}} returns 7
{{MONTHNUMBER<nowiki>|august}} returns 8
{{MONTHNUMBER<nowiki>|september}} returns 9
{{MONTHNUMBER<nowiki>|october}} returns 10
{{MONTHNUMBER<nowiki>|november}} returns 11
{{MONTHNUMBER<nowiki>|december}} returns 12

Examples for all abbreviated English month names[edit source]

{{MONTHNUMBER<nowiki>|jan}} returns 1
{{MONTHNUMBER<nowiki>|feb}} returns 2
{{MONTHNUMBER<nowiki>|mar}} returns 3
{{MONTHNUMBER<nowiki>|apr}} returns 4
{{MONTHNUMBER<nowiki>|may}} returns 5
{{MONTHNUMBER<nowiki>|jun}} returns 6
{{MONTHNUMBER<nowiki>|jul}} returns 7
{{MONTHNUMBER<nowiki>|aug}} returns 8
{{MONTHNUMBER<nowiki>|sep}} returns 9
{{MONTHNUMBER<nowiki>|oct}} returns 10
{{MONTHNUMBER<nowiki>|nov}} returns 11
{{MONTHNUMBER<nowiki>|dec}} returns 12

Examples for all standard month numbers[edit source]

{{MONTHNUMBER<nowiki>|1}} returns 1
{{MONTHNUMBER<nowiki>|2}} returns 2
{{MONTHNUMBER<nowiki>|3}} returns 3
{{MONTHNUMBER<nowiki>|4}} returns 4
{{MONTHNUMBER<nowiki>|5}} returns 5
{{MONTHNUMBER<nowiki>|6}} returns 6
{{MONTHNUMBER<nowiki>|7}} returns 7
{{MONTHNUMBER<nowiki>|8}} returns 8
{{MONTHNUMBER<nowiki>|9}} returns 9
{{MONTHNUMBER<nowiki>|10}} returns 10
{{MONTHNUMBER<nowiki>|11}} returns 11
{{MONTHNUMBER<nowiki>|12}} returns 12

Examples for month numbers with extra leading zero[edit source]

{{MONTHNUMBER<nowiki>|01}} returns 1
{{MONTHNUMBER<nowiki>|02}} returns 2
{{MONTHNUMBER<nowiki>|03}} returns 3
{{MONTHNUMBER<nowiki>|04}} returns 4
{{MONTHNUMBER<nowiki>|05}} returns 5
{{MONTHNUMBER<nowiki>|06}} returns 6
{{MONTHNUMBER<nowiki>|07}} returns 7
{{MONTHNUMBER<nowiki>|08}} returns 8
{{MONTHNUMBER<nowiki>|09}} returns 9

Example for invalid month name[edit source]

{{MONTHNUMBER<nowiki>|xx}} returns Expression error: Unrecognized word "xx".