This site is supported by donations to The OEIS Foundation.

Template:Daynum

From OeisWiki
Jump to: navigation, search

The {{daynum}} date and time function template changes a full weekday name, a standard three letter weekday abbreviation or a weekday number from 0 to 6, with or without a leading zero, to the weekday number from 0 to 6.

Usage

{{daynum|a full weekday name, a standard three letter weekday abbreviation or a weekday number from 0 to 6, with or without a leading zero}}

or

{{daynum}} which defaults to local weekday number of OEIS Wiki server

Examples

Examples with valid input

Code Result
{{daynum|monday}} 1
{{daynum|Monday}} 1
{{daynum|WEDNESDAY}} 3
{{daynum|tue}} 2
{{daynum|0}} 0
{{daynum|4}} 4
{{daynum|06}} 6
{{daynum|001}} 1
{{daynum}} 5

Examples with invalid input

Code Result
{{daynum|Hexday}} Daynum error: invalid input
{{daynum|7}} Daynum error: invalid input
{{daynum|-1}} Daynum error: invalid input
{{daynum|6.5}} Daynum error: invalid input

Code

<!-- The third column will have its use! For the third column, the leading zeros are ignored. -->

{{#switch: {{lc: {{{1|{{LOCALDAYNAME}}}}} }}
  | sunday=0    | sun=0 | 0=0
  | monday=1    | mon=1 | 1=1
  | tuesday=2   | tue=2 | 2=2
  | wednesday=3 | wed=3 | 3=3
  | thursday=4  | thu=4 | 4=4
  | friday=5    | fri=5 | 5=5
  | saturday=6  | sat=6 | 6=6
  | {{error| Daynum error: invalid input}}
}}

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)