1 package HTML::CalendarMonth::DateTool::DateCalc;
3 # Interface to Date::Calc
8 use vars qw(@ISA $VERSION);
10 @ISA = qw(HTML::CalendarMonth::DateTool);
14 use Date::Calc qw(Days_in_Month Day_of_Week Add_Delta_Days
15 Weeks_in_Year Week_of_Year Week_Number Mktime
18 sub dow1st_and_lastday {
19 my($self, $month, $year) = @_;
20 $month ||= $self->month;
21 $year ||= $self->year;
22 my $lastday = Days_in_Month($year, $month);
23 # Date::Calc uses 1..7 as indicies in the week, starting with Monday.
24 # Internally, we use 0..6, starting with Sunday. These turn out to be
25 # identical except for Sunday.
26 my $dow1st = $self->dow(1);
27 $dow1st = 0 if $dow1st == 7;
32 my($self, $day, $month, $year) = @_;
33 $month ||= $self->month;
34 $year ||= $self->year;
35 Mktime($year, $month, $day, 0, 0, 0);
39 my($self, $day, $month, $year) = @_;
40 $day || croak "Day required.\n";
41 $month ||= $self->month;
42 $year ||= $self->year;
43 Day_of_Week($year, $month, $day);
47 my($self, $delta, $day, $month, $year) = @_;
48 $delta || croak "Delta (in days) required.\n";
49 $day || croak "Day required.\n";
50 $month ||= $self->month;
51 $year ||= $self->year;
52 my($y, $m, $d) = Add_Delta_Days($year, $month, $day, $delta);
57 my($self, $day, $month, $year) = @_;
58 $day || croak "Day required.\n";
59 $month ||= $self->month;
60 $year ||= $self->year;
62 ($week, $year) = Week_of_Year($year, $month, $day);