Talk:ISO week date

From Wikipedia, the free encyclopedia

WikiProject Time This article is within the scope of WikiProject Time, an attempt to build a comprehensive and detailed guide to Time on Wikipedia. If you would like to participate, please join the project.
B This article has been rated as B-Class on the quality scale.
Mid This article has been rated as Mid-importance on the Project's importance scale.

Contents

[edit] WikiProject Time assessment rating comment

Nearly a B.

Want to help write or improve articles about Time? Join WikiProject Time or visit the Time Portal for a list of articles that need improving.
Yamara 18:18, 14 February 2008 (UTC)

[edit] Discussion

Ok, I understand now "What if most years had a leap week?". What matters for the maximum change of corresponding equinoxes between two years is the largest deviation of a year from the average year.--Patrick 21:38, 30 May 2006 (UTC)

[edit] Use of term "Leap Week"

I have seen ISO 8601:2000 but not ISO 8601:2004. ISO 8601:2000 does not use the term "leap week"; I don't know whether ISO 8601:2004 does.

Unless the term is introduced in ISO 8601:2004, it seems to me unwise to introduce it elsewhere; "week 53" suffices. It leads to using "leap year" for 53-week years, which clashes with conventional use. It might be thought to mean a week containing February 29th.

Re section "Disadvantages" : The ISO Week Calendar could fully replace the Gregorian, because it is possible to calculate Day 1 of a given year directly - but the expression will be more complicated.

Re section "Advantages" : Although the date of Easter Sunday would be no easier to calculate, the number of possible dates would be less, since all are Day 7. Only a few Week Numbers would be possible.

82.163.24.100 13:45, 30 January 2007 (UTC)

Only six Week Numbers, 12-17 would be possible, 17 being rare.

82.163.24.100 22:19, 3 February 2007 (UTC)

ISO 8601:2004 does not use "leap week". It does use "leap year", but in the common sense of a year with 366 days; accordingly, "leap year" should not be used to refer to an ISO year of 53 weeks.

Library routines purporting to convert other forms of date into ISO week dates should be viewed with caution; errors are known to occur, for example with 2007-12-31.

There is only ONE definition of Week 01; it is in ISO 8601:2004 2.2.10, and uses 'first Thursday' (and see 3.2.2 note 3). The others are mere equivalent consequential descriptions.

82.163.24.100 10:52, 26 May 2007 (UTC)

[edit] Templates

[edit] Disadvantage question

I don't get this part: "It cannot replace the Gregorian calendar, because it relies on it to define the new year day (Week 1 Day 1)."

Is what you want to say that if it coexists with the Gregorian Calendar then it has to be decided which one of them that tells when to celebrate new year's eve since the days for a new year differs?

I can see no logical reason to why new year couldn't be defined as Week 1 Day 1. I mean it's pretty much how it is now with the leap days, we don't celebrate the new year on different times on the day even if it supposedly moves approx 6 hours each year.

--Crouz 20:50, 4 November 2007 (UTC)

[edit] Algorithms

Having seen the rubbishy code of two major software suppliers, and noting that the recent products of one have code which is not only bloated but wrong, I think that adding something on Algorithms would be justified.

To convert a Gregorian date into an ISO 8601 Week Numbering date Y W D, all that is necessary is to :-

 Determine its Day of Week, D
 Use that to move to the nearest Thursday (-3..+3 days)
 Note the year of that date, Y
 Obtain January 1 of that year
 Get the Ordinal Date of that Thursday, DDD of YYYY-DDD
 Then W is 1 + (DDD-1) div 7

or very similar.

Observe that there is no need to consider any special cases.

Here are well-tested Delphi routines for the comversions of a TDateTime (Local daycount from 1899-12-30 00:00:00 = 0.0) to and from Y W D form :-

procedure ISODTtoYWD(const DT : TDateTime ; out YN, WN, DN : word) ;
var X : word ; NThu, Jan1 : TDateTime ;
begin // The canonical version.
  DN := 1 + (DayOfWeek(DT)+5) mod 7 { DT : Mon=1 to Sun=7 } ;
  NThu := Trunc(DT) + 4 - DN { NThu is the Nearest Thursday } ;
  DecodeDate(NThu, YN, X, X) { get Year Number of NThu } ;
  Jan1 := EncodeDate(YN, 1, 1) { January 1 of YN } ;
  WN := 1 + Trunc(NThu-Jan1) div 7 { Count of Thursdays } ;
  end {ISODTtoYWD} ;
function ISOYWDtoDT(const YN, WN, DN : word) : TDateTime ;
var DT : TDateTime ; DW : integer ;
begin // The canonical version.
  DT := EncodeDate(YN, 1, 4) { YN Jan 4, which is in YN Week 1 } ;
  DW := 1 + (DayOfWeek(DT)+5) mod 7 { DT : Mon=1 to Sun=7 } ;
  DT := DT - DW { DT to day before Week 1 } ;
  Result := DT + (WN-1)*7 + DN { increment for Weeks and Days } ;
  end {ISOYWDtoDT} ;

A slight speed-up is possible, at the expense of clarity.

Javascript versions are in http://www.merlyn.demon.co.uk/weekcalc.htm .

82.163.24.100 (talk) 21:19, 19 March 2008 (UTC)

[edit] logic error found

The definition of the first week in the iso calendar mentions:

Mutually equivalent definitions for week 01 are:

the week with the year's first Thursday in it

the week with January 4 in it


However this cannot be true, for in 2009 they fall on different weeks:

  January 2009
 S  M Tu  W Th  F  S
             1  2  3
 4  5  6  7  8  9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

—Preceding unsigned comment added by 192.65.45.20 (talk • contribs)

As mentioned, in this system weeks start with Monday.--Patrick (talk) 23:51, 6 June 2008 (UTC)