X-Git-Url: https://git.donarmstrong.com/?p=deb_pkgs%2Flibhtml-calendarmonth-perl.git;a=blobdiff_plain;f=current%2Flib%2FHTML%2FCalendarMonth%2FDateTool%2FDateCalc.pm;fp=current%2Flib%2FHTML%2FCalendarMonth%2FDateTool%2FDateCalc.pm;h=38cbcbb3869b7bcacb585f0e90081ffbe49ce3c2;hp=90612f6f2cc476200c98404a0b7be334d4ef8b65;hb=2a7fc55a2e563096c7348a2f6272a16830561513;hpb=e572b7973fb212cb24fbefc385f28f473f02df0c diff --git a/current/lib/HTML/CalendarMonth/DateTool/DateCalc.pm b/current/lib/HTML/CalendarMonth/DateTool/DateCalc.pm index 90612f6..38cbcbb 100644 --- a/current/lib/HTML/CalendarMonth/DateTool/DateCalc.pm +++ b/current/lib/HTML/CalendarMonth/DateTool/DateCalc.pm @@ -1,31 +1,31 @@ package HTML::CalendarMonth::DateTool::DateCalc; +BEGIN { + $HTML::CalendarMonth::DateTool::DateCalc::VERSION = '1.25'; +} # Interface to Date::Calc use strict; +use warnings; use Carp; -use vars qw(@ISA $VERSION); - -@ISA = qw(HTML::CalendarMonth::DateTool); - -$VERSION = '0.03'; +use base qw( HTML::CalendarMonth::DateTool ); -use Date::Calc qw(Days_in_Month Day_of_Week Add_Delta_Days - Weeks_in_Year Week_of_Year Week_Number Mktime - ); +use Date::Calc qw( + Days_in_Month + Day_of_Week + Add_Delta_Days + Weeks_in_Year + Week_of_Year + Week_Number + Mktime +); sub dow1st_and_lastday { my($self, $month, $year) = @_; $month ||= $self->month; $year ||= $self->year; - my $lastday = Days_in_Month($year, $month); - # Date::Calc uses 1..7 as indicies in the week, starting with Monday. - # Internally, we use 0..6, starting with Sunday. These turn out to be - # identical except for Sunday. - my $dow1st = $self->dow(1); - $dow1st = 0 if $dow1st == 7; - ($dow1st, $lastday); + ($self->dow(1), Days_in_Month($year, $month)); } sub day_epoch { @@ -37,16 +37,18 @@ sub day_epoch { sub dow { my($self, $day, $month, $year) = @_; - $day || croak "Day required.\n"; + $day || croak "day required.\n"; $month ||= $self->month; $year ||= $self->year; - Day_of_Week($year, $month, $day); + # Date::Calc uses 1..7 as indicies in the week, starting with Monday. + # Convert to 0..6, starting with Sunday. + Day_of_Week($year, $month, $day) % 7; } sub add_days { my($self, $delta, $day, $month, $year) = @_; - defined $delta || croak "Delta (in days) required.\n"; - $day || croak "Day required.\n"; + defined $delta || croak "delta (in days) required.\n"; + $day || croak "day required.\n"; $month ||= $self->month; $year ||= $self->year; my($y, $m, $d) = Add_Delta_Days($year, $month, $day, $delta); @@ -55,7 +57,7 @@ sub add_days { sub week_of_year { my($self, $day, $month, $year) = @_; - $day || croak "Day required.\n"; + $day || croak "day required.\n"; $month ||= $self->month; $year ||= $self->year; my $week;