Hello John Peacock, in a previous mail you wrote: > >I've just had a problem related to the Date::Calc modules calculation of > >week numbers, as some of my data suppliers are obviously using a different > >algorithm to calculate week 1 of a year - they define dates which fall > >into week 1 of 2003 according to Date::Calc as week 53 of 2002. > > I suspect you are looking for ISO-8601, which is the applicable > International standard. Also see this very nice FAQ: > http://www.tondering.dk/claus/cal/node6.html#SECTION00680000000000000000 > for a discussion of (and formula for) calculating week number. > > >I need to know the criteria for defining week 1 of a year according to > >Date::Calc to check which data suppliers match, and which I need to create > >custom week number generators for. From the documentation, I suspect it > >might be the week containing the 1si of January, with Monday defined as > >the first day of a week, but I can't find it confirmed anywhere. Does > >anyone know what it uses? > > According to the prior section of the above FAQ: > http://www.tondering.dk/claus/cal/node6.html#SECTION00670000000000000000 > > since the first Thusday in January is Jan 2, 2003, that is Week 1 (and > hence Date::Calc is "wrong").
Date::Calc isn't "wrong". You probably didn't read the documentation carefully enough. However, I do apologize if the documentation maybe isn't obvious enough regarding this point. Date::Calc correctly states that the first week of 2003 starts on Monday December 30th 2002. (Please verify: http://www.engelschall.com/~sb/calendar/?language=1&myear=2003&month=1) You must have used the (deprecated) function "Week_Number()" instead of ($week,$year) = Week_of_Year($year,$month,$day); The manual page says about "Week_Number()": o "$week = Week_Number($year,$month,$day);" This function returns the number of the week the given date lies in. If the given date lies in the LAST week of the PREVIOUS year, "0" is returned. If the given date lies in the FIRST week of the NEXT year, ""Weeks_in_Year($year) + 1"" is returned. As you can easily verify using the function "Weeks_in_Year($year)", 2002 only has 52 weeks. Therefore, the result 53 correctly means "week number 1 of the next year". By using "Week_of_Year()" instead, you'll avoid any ambiguity there might be otherwise. > Note also the last line of that answer (that > this numbering is not used in the US). > > HTH > John Hope this helps to clarify the misunderstanding. :-) Cheers, -- Steffen Beyer <[EMAIL PROTECTED]> http://www.engelschall.com/u/sb/whoami/ (Who am I) http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...) http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)
