From Encyclopedia Thelemica
Revision as of 13:42, 5 August 2010 by Hecate (talk | contribs) (New page: <includeonly>{{{{{subst|}}}evalp| ((((({{{1|}}})*12+({{{2|1}}})+57608.5 round 0)/12-1.5 round 0)*1461/4-0.5 round 0) -(((({{{1|}}})*12+({{{2|1}}})+57608.5 round 0)/12-1.5 round 0)/100-0.5 ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
[edit] [purge] 50px Template documentation


This template computes the ISO weekday number (1=Monday, ..., 7=Sunday) for a given Gregorian date (including proleptic years, down to at least 4800 BC, near the theoretical start of the old Roman calendar, and up to at least 5000 AD).

Alternative weekday number systems are:

  • 1=Monday, ..., 6=Saturday, 0=Sunday, used by variable {{CURRENTDOW}}
    • {{CURRENTDOW}} currently gives 3.
  • 0=Monday, ..., 5=Saturday, 6=Sunday, used by en:Template:WEEKDAY and fr:Modèle:WEEKDAY

The formula used to compute the weekday is purely cyclic, using only modular arithmetic operations and small integers (that can fit exactly within floating point variables), excluding all tests (with limited accepted value ranges). This allows all the parameters to be used linearly, including the month and day which are not required to be within 1 and the total numer of days in the indicated month and/or year.

So for computing the weekday number for a date which is N years, P months and Q days after another date known as y|m|d, you can safely use this template with y+N|m+P|d+Q, instead of having to determine the adjusted three elements of the target date with complex formulas (just to remain within the accepted limits of this function), as long as the target date remains within the Gregorian calendar (or proleptic Gregorian), i.e. after 4800BC, and covering all late Biblic dates, medieval, modern and contemporary dates, as well as future dates for several milleniums.


  • The year must be astronomical (year=1 in 1 AD (Anno Domini), year=0 in 1 BC, year=-1 in 2 BC).
  • The month is between 1 and 12 from january to december.
  • The day is normally between 1 and 31.


  • "{{ISOWEEKDAY|2005|12|31}}" gives "6" [1], and is eqv. with "{{ISOWEEKDAY|2006|1|0}}" gives "6" [2]
  • "{{ISOWEEKDAY|2006|1|1}}" gives "7" [3]
  • "{{ISOWEEKDAY|2006|1|2}}" gives "1" [4]

Examples where the ISO year is three days into the next gregorian year

  • "{{ISOWEEKDAY|2009|12|31}}" gives "4" [5]
  • "{{ISOWEEKDAY|2010|1|1}}" gives "5" [6]
  • "{{ISOWEEKDAY|2010|1|2}}" gives "6" [7]
  • "{{ISOWEEKDAY|2010|1|3}}" gives "7" [8]
  • "{{ISOWEEKDAY|2010|1|4}}" gives "1" [9]

Examples where the ISO year is three days into the previous gregorian year

  • "{{ISOWEEKDAY|2008|12|28}}" gives "7" [10]
  • "{{ISOWEEKDAY|2008|12|29}}" gives "1" [11]
  • "{{ISOWEEKDAY|2008|12|30}}" gives "2" [12]
  • "{{ISOWEEKDAY|2008|12|31}}" gives "3" [13]
  • "{{ISOWEEKDAY|2009|1|1}}" gives "4" [14]

See also

dsb:Pśedłoga:ISOWEEKDAY hsb:Předłoha:ISOWEEKDAY ja:Template:ISOWEEKDAY no:Mal:ISOWEEKDAY stq:Foarloage:ISOWEEKDAY