This site is supported by donations to The OEIS Foundation.
Template:Days in month
From OeisWiki
(Redirected from Template:Monthdays)
The following documentation is located at Template:Days in month/doc. [<Edit> Template:Days in month/doc]
[⧼Purge⧽ Template:Days in month]
[⧼Purge⧽ Template:Days in month]
The {{days in month}} (or {{monthdays}}) date and time function template returns the number of days in a month (given as a full month name, a standard three letter month abbreviation or a month number (up to two digits) from 01 to 12, with or without a leading zero) in a year given as an up to four decimal digits number in [1..10000].
Years from 1 AD to 10000 AD are considered, while BC years are not considered. Note that there was no year 0, since the ancient Greeks and Romans had no concept of zero. Abides by the following two calendars
- Julian calendar from 1 to 1581 (in 46 BC, Julius Caesar reformed the Roman calendar with leap years (given by a simple rule,) but many errors were committed and corrections applied until year 4 AD inclusive; The UNIX command cal incorrectly lists 4 AD as a leap year (Vardi 1991);)
- Gregorian calendar from 1582 to 10000 (in 1582, Pope Gregory XIII decreed that the day after October 4, 1582 would be October 15, 1582. He also decreed a more sophisticated rule for determining leap years.)
Contents
Usage
- {{monthdays|month|year}}
or
- {{monthdays|month}} where the year defaults to local year of OEIS Wiki server
or
- {{monthdays}} where both the month and the year default to local month and local year of OEIS Wiki server
Examples
Examples with valid input
Code Result {{monthdays|jan}} 31 {{monthdays|feb}} 29 {{monthdays|feb|4}} 28 {{monthdays|feb|8}} 29 {{monthdays|feb|+10}} 28 {{monthdays|feb|12}} 29 {{monthdays|feb|1196}} 29 {{monthdays|feb|1200}} 29 {{monthdays|feb|1204}} 29 {{monthdays|feb|1300}} 29 {{monthdays|feb|1582}} 28 {{monthdays|feb|1896}} 29 {{monthdays|feb|1900}} 28 {{monthdays|feb|2000}} 29 {{monthdays|feb|2003}} 28 {{monthdays|feb|2004}} 29 {{monthdays|feb|9999}} 28 {{monthdays|mar}} 31 {{monthdays|apr}} 30 {{monthdays|may}} 31 {{monthdays|jun}} 30 {{monthdays|jul}} 31 {{monthdays|jul|1}} 31 {{monthdays|jul|+1}} 31 {{monthdays|aug}} 31 {{monthdays|sep}} 30 {{monthdays|oct}} 31 {{monthdays|feb|1580}} 29 {{monthdays|oct|1581}} 31 {{monthdays|oct|1582}} 21 {{monthdays|oct|1583}} 31 {{monthdays|nov}} 30 {{monthdays|dec}} 31 {{monthdays|january}} 31 {{monthdays|January}} 31 {{monthdays|jul}} 31 {{monthdays|SEPTEMBER}} 30 {{monthdays|4}} 30 {{monthdays|06}} 30 {{monthdays|007}} 31 {{monthdays}} 30
Examples with invalid input
Code Result {{monthdays|feb|10000}} 29 {{monthdays|jul|-1}} Monthdays error: Year must be in [1..10000] (up to four digits, AD years only, there was no year 0) {{monthdays|jul|0}} Monthdays error: Year must be in [1..10000] (up to four digits, AD years only, there was no year 0) {{monthdays|Hexember}} Monthdays error: Invalid month {{monthdays|13}} Monthdays error: Invalid month {{monthdays|-1}} Monthdays error: Invalid month {{monthdays|6.5}} Monthdays error: Invalid month
Code
{{#ifexpr: ( ( {{{2|{{LOCALYEAR}}}}} >= 1 ) and ( {{{2|{{LOCALYEAR}}}}} <= 10000 ) ) <!-- AD years (positive) up to 10000 only, BC years (negative) not considered, note that there was no year 0 --> <!-- Since Oct 15 1582, the Gregorian calendar disagrees with the Julian calendar for the month of February and for the month of October in 1582 when 10 days where skipped (no Oct 5 to Oct 14.) --> | {{#switch: {{monthnum| {{{1|{{LOCALMONTH}}}}}}} | 01= 31 | 02= {{ifleapyear| {{{2|{{LOCALYEAR}}}}}|29|28}} | 03= 31 | 04= 30 | 05= 31 | 06= 30 | 07= 31 | 08= 31 | 09= 30 | 10= <!-- Abides by the Gregorian calendar. (Pope Gregory XIII decreed that the day after October 4, 1582 would be October 15, 1582.) --> {{#ifexpr: ( {{{2|{{LOCALYEAR}}}}} = 1582 ) | 21 | 31 }} | 11= 30 | 12= 31 | {{error| Monthdays error: Invalid month}} }} | {{error| Monthdays error: Year must be in [1..10000] (up to four digits, AD years only, there was no year 0)}} }}
See also
- {{daynum}} gives the weekday number (0 to 6) for (Sun to Sat)
- {{day}} gives the standard three letter weekday abbreviation.
- {{fullday}} gives the full weekday name.
- {{monthnum}} gives the month number (padded left with 0 if necessary to get two decimal digits) (01 to 12)
- {{month}} gives the standard three letter month abbreviation.
- {{fullmonth}} gives the full month name.
- {{days in month}} (or {{monthdays}}) gives the number of days in a month (for any year from 1 AD to 10000 AD)
- {{yearday}} returns the day of year from year, month and monthday (for any year from 1 AD to 10000 AD)
- {{ifleapyear}} or {{if leap year}} returns different values depending on whether a given year is a leap year or a common year (for any year from 1 AD to 10000 AD)
- {{is leap year}} predicate function template returns 1 (if true) or 0 (if false) depending on whether a given year is a leap year or a common year (for any year from 1 AD to 10000 AD)
- {{Century}} returns the century for any nonzero (negative or positive) year
- {{Millennium}} returns the millennium for any nonzero (negative or positive) year
- {{to day of CE}} returns the day of CE (Christ Era) from year, month and monthday (for any year from 1 AD to 10000 AD)
- {{from day of CE}} returns year, month and monthday (for any year from 1 AD to 10000 AD) from the day of CE (Christ Era)
- {{date}} for date mathematics (for any year from 1 AD to 10000 AD) (returns the date offset a specified number of days from a given date)
- {{days between}} for date mathematics (for any years from 1 AD to 10000 AD) (returns the number of days between two dates)
External links
- Scienceworld, Gregorian Calendar, © 1996-2007 Eric W. Weisstein.
- Scienceworld, Julian Calendar, © 1996-2007 Eric W. Weisstein.
- Scienceworld, Roman Calendar, © 1996-2007 Eric W. Weisstein.