Jump to content

Template:Isoyear

From Meta, a Wikimedia project coordination wiki
(Redirected from Template:ISOYEAR)


  • "{{isoyear|2006|1|1}}" gives "2005" [1]
  • "{{isoyear|2006|1|2}}" gives "2006" [2]

{{subst:isoyear|2006|1|1|subst=subst:}} gives the wikitext 2005.

This template computes the number of the ISO year for a date of the Gregorian calendar and its backward extrapolation, the proleptic Gregorian calendar. Any ISO year always consists of 52 or 53 full weeks from Monday through Sunday.

The ISO year starts at the first day (Monday) of week 01 and ends at the Sunday before the new ISO year (hence without overlap or gap). The ISO year number deviates from the number of the normal year (Gregorian year) on, if applicable, a Friday, Saturday, and Sunday, or a Saturday and Sunday, or just a Sunday, at the start of the ordinary year (which are at the end of the previous ISO year) and a Monday, Tuesday and Wednesday, or a Monday and Tuesday, or just a Monday, at the end of the ordinary year (which are in week 01 of the next ISO year). In the period 4 January - 28 December and on all Thursdays the ISO year number is always equal to the ordinary year number.

Equivalent definitions for week 01 are:

  • the week with the year's first Thursday in it
  • the week with the year's first working day in it (if Saturdays, Sundays, and 1 January are no working days)
  • the week with January 4 in it
  • the first week with the majority (four or more) of its days in the starting year
  • the week starting with the Monday in the period 29 December - 4 January
  • the week with the Thursday in the period 1 - 7 January
  • If 1 January is on a Monday, Tuesday, Wednesday or Thursday, it is in week 01. If 1 January is on a Friday, Saturday or Sunday, it is in week 52 or 53 of the previous year.

The last week of the ISO year is the week before week 01; in accordance with the symmetry of the definition, equivalent definitions are:

  • the week with the year's last Thursday in it
  • the week with December 28 in it
  • the last week with the majority (four or more) of its days in the ending year
  • the week starting with the Monday in the period 22 - 28 December
  • the week with the Thursday in the period 25 - 31 December
  • the week ending with the Sunday in the period 28 December - 3 January
  • If 31 December is on a Monday, Tuesday, or Wednesday, it is in week 01, otherwise in week 52 or 53.

The following years have 53 weeks:

  • years starting with Thursday
  • leap years starting with Wednesday

Examples:

  • 2008-12-29 is written 2009-W01-1 or in its most compact form 09W011.
  • 2010-01-03 is written 2009-W53-7 or in its most compact form 09W537.

Method

[edit]

{{#switch:{{{2|{{CURRENTMONTH}}}}}|1={{#ifexpr:{{{3|{{CURRENTDAY}}}}}<5-{{DOW|{{{1|{{CURRENTYEAR}}}}}|1|4}}|{{#expr:{{{1|{{CURRENTYEAR}}}}}-1}}|{{{1|{{CURRENTYEAR}}}}}}}|12={{#ifexpr:{{{3|{{CURRENTDAY}}}}}>=36-{{DOW|{{{1|{{CURRENTYEAR}}}}}|12|28}}|{{#expr:{{{1|{{CURRENTYEAR}}}}}+1}}|{{{1|{{CURRENTYEAR}}}}}}}|{{{1|{{CURRENTYEAR}}}}}}}


other method:


{{MJD2Y|{{#expr:( {{YMD2MJD|{{{1|{{CURRENTYEAR}}}}}|{{{2|{{CURRENTMONTH}}}}}|{{{3|{{CURRENTDAY}}}}}}} - {{DOW|{{{1|{{CURRENTYEAR}}}}}|{{{2|{{CURRENTMONTH}}}}}|{{{3|{{CURRENTDAY}}}}}}} ) + 4}}}}


See also

[edit]