in reply to Date::Manip week-of-year

Just a side note--I realize the problem is solved, so this is more of a response to runrig's 'arbitrary' comment--by definition, the first week of the year is whatever week includes 4 January, so it's possible for the 31st of December to be part of week 1 of the new year, or for 1 January to be part of the last week of the old year. You won't notice this with 2000-1, but 2001-2 doesn't divide as neatly.
  • Comment on (kudra: 4 jan is in week 1) RE: Date::Manip week-of-year

Replies are listed 'Best First'.
RE: (kudra: 4 jan is in week 1) RE: Date::Manip week-of-year
by royalanjr (Chaplain) on Oct 04, 2000 at 19:10 UTC
    Ok, question:
    <dunce cap> Why is the first week defined that way? </dunce cap>
    eerrr.... maybe I had best leave it on....

    Roy Alan

      I believe Date::Manip treats the first week of the year as the week that January 1st is in. A week is still Sunday -> Saturday (or Monday -> Sunday?), so if January 1st is on a Friday, several of the days at the end of December will be treated as being part of the first week of that year.

      How would you define it? With varying "week" boundaries? One year a week starts on a Wednesday, the next it starts on a Friday? Would you break up a week into two pieces, calling the first piece week 52 and the 2nd piece week 1?

      It makes sense in a weird sort of way.

        From perldoc Date::Manip...
        ** Note that the formats "sunday week 22" and "22nd sunday" give very different bahaviors. "sunday week 22" returns the sunday of the 22nd week of the year based on how week 1 is defined. ISO 8601 defines week one to contain Jan 4, so "sunday week 1" might be the first or second sunday of the current year, or the last sunday of the previous year. "22nd sunday" gives the actual 22nd time sunday occurs in a given year, regardless of the definition of a week.

        -- Randal L. Schwartz, Perl hacker