This site is supported by donations to The OEIS Foundation.

Template:Yearday

From OeisWiki
Jump to: navigation, search

The {{yearday}} date and time template returns the day of year for a given year, month and monthday.

Usage

{{yearday|year=year as a nonzero unformatted integer in [1..10000]|month=month as two digit number in [1..12], abbreviation or full name|monthday=day of month}}

or

{{yearday|year as a nonzero unformatted integer in [1..10000]|month as two digit number in [1..12], abbreviation or full name|day of month}}

or

{{yearday}} where year, month and monthday default to local year, local month and local monthday of OEIS Wiki server

Examples

Examples with valid input

code result
{{yearday}} 128
{{yearday|year=2011|month=01|monthday=10}} 10
{{yearday|year=2011|month=Feb|monthday=10}} 41
{{yearday|2011|Feb|10}} 41
{{yearday|year=2011|month=03|monthday=10}} 69
{{yearday|year=2011|month=Apr|monthday=10}} 100
{{yearday|year=2011|month=May|monthday=10}} 130
{{yearday|year=2011|month=June|monthday=10}} 161
{{yearday|year=2011|month=07|monthday=10}} 191
{{yearday|year=2011|month=08|monthday=10}} 222
{{yearday|year=2011|month=09|monthday=10}} 253
{{yearday|year=2011|month=10|monthday=10}} 283
{{yearday|year=2011|month=11|monthday=10}} 314
{{yearday|year=2011|month=12|monthday=10}} 344
{{yearday|year=2011|month=Dec|monthday=31}} 365
{{yearday|year=2004|month=Dec|monthday=31}} 366
{{yearday|year=2005|month=Jan|monthday=01}} 1
{{yearday|year=2005|month=Dec|monthday=01}} 335
{{yearday|year=2000|month=Jan|monthday=20}} 20
{{yearday|year=2000|month=Feb|monthday=29}} 60
{{yearday|year=2000|month=Mar|monthday=20}} 80
{{yearday|year=2000|month=Dec|monthday=31}} 366
{{yearday|year=1900|month=Jan|monthday=20}} 20
{{yearday|year=1900|month=Feb|monthday=20}} 51
{{yearday|year=1900|month=Mar|monthday=20}} 79
{{yearday|year=1900|month=Dec|monthday=31}} 365
{{yearday|year=1582|month=Sep|monthday=30}} 273
{{yearday|year=1582|month=Oct|monthday=4}} 277
{{yearday|year=1582|month=Oct|monthday=5}} Yearday error: Invalid monthday (in 1582, Pope Gregory XIII decreed that the day after October 4, 1582 would be October 15, 1582)
{{yearday|year=1582|month=Oct|monthday=10}} Yearday error: Invalid monthday (in 1582, Pope Gregory XIII decreed that the day after October 4, 1582 would be October 15, 1582)
{{yearday|year=1582|month=Oct|monthday=14}} Yearday error: Invalid monthday (in 1582, Pope Gregory XIII decreed that the day after October 4, 1582 would be October 15, 1582)
{{yearday|year=1582|month=Oct|monthday=15}} 278
{{yearday|year=1582|month=Oct|monthday=31}} 294
{{yearday|year=1582|month=Nov|monthday=30}} 324
{{yearday|year=1582|month=Dec|monthday=31}} 355
{{yearday|year=16|month=Dec|monthday=31}} 366
{{yearday|year=12|month=Dec|monthday=31}} 366
{{yearday|year=8|month=Dec|monthday=31}} 366
{{yearday|year=4|month=Dec|monthday=31}} 365
{{yearday|year=1|month=Dec|monthday=31}} 365

Examples with invalid input

code result
{{yearday|year=0|month=Sep|monthday=30}} Yearday error: Year must be an integer in [1..10000]
{{yearday|year=50 BC|month=Sep|monthday=30}} Yearday error: Year must be a nonzero unformatted integer in [1..10000]
{{yearday|year=-50|month=Sep|monthday=30}} Yearday error: Year must be an integer in [1..10000]
{{yearday|year=0|month=Sep|monthday=30}} Yearday error: Year must be an integer in [1..10000]
{{yearday|year=20000|month=Sep|monthday=30}} Yearday error: Year must be an integer in [1..10000]
{{yearday|year=1600 AD|month=13|monthday=31}} Yearday error: Year must be a nonzero unformatted integer in [1..10000]
{{yearday|year=1600|month=13|monthday=31}} Yearday error: Invalid month
{{yearday|year=1600|month=0|monthday=31}} Yearday error: Invalid month
{{yearday|year=1600|month=Hexember|monthday=31}} Yearday error: Invalid month
{{yearday|year=1600|month=08|monthday=0}} Yearday error: Monthday must be in [1..31] for August 1600
{{yearday|year=1600|month=08|monthday=32}} Yearday error: Monthday must be in [1..31] for August 1600
{{yearday|year=1600|month=Sep|monthday=31}} Yearday error: Monthday must be in [1..30] for September 1600
{{yearday|year=2000|month=Feb|monthday=30}} Yearday error: Monthday must be in [1..29] for February 2000
{{yearday|year=1900|month=Feb|monthday=29}} Yearday error: Monthday must be in [1..28] for February 1900

Code


{{ifint| {{{year|{{{1|{{LOCALYEAR}}}}}}}}
| {{#ifexpr: ( ( {{{year|{{{1|{{LOCALYEAR}}}}}}}} >= 1 ) and ( {{{year|{{{1|{{LOCALYEAR}}}}}}}} <= 10000 ) )
  | {{#iferror: {{monthnum|{{{month|{{{2|{{LOCALMONTH}}}}}}}}}}
    | {{error|Yearday error: Invalid month}}  
    | {{#ifexpr: ( ( {{{monthday|{{{3|{{LOCALDAY}}}}}}}} >= 1 ) and ( {{{monthday|{{{3|{{LOCALDAY}}}}}}}} <= {{monthdays|{{{month|{{{2|{{LOCALMONTH}}}}}}}}|{{{year|{{{1|{{LOCALYEAR}}}}}}}}}} + 
      {{#ifexpr: ( ( {{{year|{{{1|{{LOCALYEAR}}}}}}}} = 1582 ) and ( {{monthnum|{{{month|{{{2|{{LOCALMONTH}}}}}}}}}} = 10 ) )
        | 10 <!-- even though Oct 5 to Oct 14 were skipped in 1582, monthday still went up to 31 -->
        | 0 
      }} ) )
      | {{#ifexpr: not ( ( {{{year|{{{1|{{LOCALYEAR}}}}}}}} = 1582 ) and ( {{monthnum|{{{month|{{{2|{{LOCALMONTH}}}}}}}}}} = 10 ) and ( {{{monthday|{{{3|{{LOCALDAY}}}}}}}} >= 5 ) and ( {{{monthday|{{{3|{{LOCALDAY}}}}}}}} <= 14 ) ) 
        | {{expr| {{{monthday|{{{3|{{LOCALDAY}}}}}}}} - 
            {{#ifexpr: ( ( {{{year|{{{1|{{LOCALYEAR}}}}}}}} = 1582 ) and ( {{monthnum|{{{month|{{{2|{{LOCALMONTH}}}}}}}}}} = 10 ) and ( {{{monthday|{{{3|{{LOCALDAY}}}}}}}} >= 15 ) )
              | 10 <!-- in 1582, Pope Gregory XIII decreed that the day after October 4, 1582 would be October 15, 1582 -->
              | 0 
            }} + 
            {{#ifexpr: {{monthnum|{{{month|{{{2|{{LOCALMONTH}}}}}}}}}} > 1|31|0}} +
            {{#ifexpr: {{monthnum|{{{month|{{{2|{{LOCALMONTH}}}}}}}}}} > 2|{{ifleapyear|{{{year|{{{1|{{LOCALYEAR}}}}}}}}|29|28}}|0}} +  
            {{#ifexpr: {{monthnum|{{{month|{{{2|{{LOCALMONTH}}}}}}}}}} > 3|31|0}} +  
            {{#ifexpr: {{monthnum|{{{month|{{{2|{{LOCALMONTH}}}}}}}}}} > 4|30|0}} +  
            {{#ifexpr: {{monthnum|{{{month|{{{2|{{LOCALMONTH}}}}}}}}}} > 5|31|0}} +  
            {{#ifexpr: {{monthnum|{{{month|{{{2|{{LOCALMONTH}}}}}}}}}} > 6|30|0}} +  
            {{#ifexpr: {{monthnum|{{{month|{{{2|{{LOCALMONTH}}}}}}}}}} > 7|31|0}} +  
            {{#ifexpr: {{monthnum|{{{month|{{{2|{{LOCALMONTH}}}}}}}}}} > 8|31|0}} +  
            {{#ifexpr: {{monthnum|{{{month|{{{2|{{LOCALMONTH}}}}}}}}}} > 9|30|0}} +  
            {{#ifexpr: {{monthnum|{{{month|{{{2|{{LOCALMONTH}}}}}}}}}} > 10|{{monthdays|Oct|{{{year|{{{1|{{LOCALYEAR}}}}}}}}}}|0}} + <!-- 1582 gotcha! --> 
            {{#ifexpr: {{monthnum|{{{month|{{{2|{{LOCALMONTH}}}}}}}}}} > 11|30|0}}    
          }}
        | {{error|Yearday error: Invalid monthday (in 1582, Pope Gregory XIII decreed that the day after October 4, 1582 would be October 15, 1582)}} 
        }}  
      | {{error|Yearday error: Monthday must be in [1..{{monthdays|{{{month|{{{2|{{LOCALMONTH}}}}}}}}|{{{year|{{{1|{{LOCALYEAR}}}}}}}}}}] for {{fullmonth|{{{month|{{{2|{{LOCALMONTH}}}}}}}}}} {{{year|{{{1|{{LOCALYEAR}}}}}}}} }}   
      }}
    }}       
  | {{error|Yearday error: Year must be an integer in [1..10000]}}   
  }}
| {{error|Yearday error: Year must be a nonzero unformatted integer in [1..10000]}}
}}

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)