Jump to content

ទំព័រគំរូ:ISOWEEKDAY/doc

ពីវិគីភីឌា

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 ៦.
  • 0=Monday, ..., 5=Saturday, 6=Sunday, used by and

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.

Syntax:

{{DOW|year|month|day}}
  • 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" [១], and is eqv. with "{{ISOWEEKDAY|2006|1|0}}" gives "6" [២]
  • "{{ISOWEEKDAY|2006|1|1}}" gives "7" [៣]
  • "{{ISOWEEKDAY|2006|1|2}}" gives "1" [៤]

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

[កែប្រែ]
  • "{{ISOWEEKDAY|2009|12|31}}" gives "4" [៥]
  • "{{ISOWEEKDAY|2010|1|1}}" gives "5" [៦]
  • "{{ISOWEEKDAY|2010|1|2}}" gives "6" [៧]
  • "{{ISOWEEKDAY|2010|1|3}}" gives "7" [៨]
  • "{{ISOWEEKDAY|2010|1|4}}" gives "1" [៩]

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

[កែប្រែ]
  • "{{ISOWEEKDAY|2008|12|28}}" gives "7" [១០]
  • "{{ISOWEEKDAY|2008|12|29}}" gives "1" [១១]
  • "{{ISOWEEKDAY|2008|12|30}}" gives "2" [១២]
  • "{{ISOWEEKDAY|2008|12|31}}" gives "3" [១៣]
  • "{{ISOWEEKDAY|2009|1|1}}" gives "4" [១៤]