Ok, I'm also _really_ confused about week_month(). What the heck is this supposed to return? For July 5, 2001 it's returning 2, which seems wrong to me, since July 5 is clearly part of the first week of July.
The comment mentions ISO but I find no reference to such a thing in ISO8601.
This one does something the old one doesn't .. it works!
# ISO says that the first week of a year is the first week containing a
# Thursday. Extending that says that the first day of the month is the
# first week containing a Thursday. ICU agrees.
sub week_month {
my $self = shift; # Faster than cloning just to get the dow
my $first_wday_of_month = (8-($self->day - $self->dow) % 7) % 7;
$first_wday_of_month = 7 unless $first_wday_of_month; # I hate to admit that I have no idea how I got this to work,
# but it does! (and I didn't copy it from a book either!)
my $wom = int(($self->day + $first_wday_of_month - 2) / 7);
return ($first_wday_of_month <= 4) ? $wom+1 : $wom;
}--
--------------------------------------------------------
There are 10 kinds of people:
those that understand binary, and those that don't.
--------------------------------------------------------
The day Microsoft makes something that doesn't suck
is the day they start selling vacuum cleaners
--------------------------------------------------------
"Write a wise proverb and your name will live forever."
-- Anonymous
--------------------------------------------------------
