1 package HTML::CalendarMonth::DateTool::DateTime;
3 # Interface to DateTime
8 use vars qw(@ISA $VERSION);
10 @ISA = qw(HTML::CalendarMonth::DateTool);
16 sub dow1st_and_lastday {
17 my($self, $month, $year) = @_;
18 $month ||= $self->month;
19 $year ||= $self->year;
20 my $lastday = $self->_last_dom_dt($year, $month);
21 my $dow1st = $self->dow(1);
22 ($dow1st, $lastday->day);
26 my($self, $day, $month, $year) = @_;
27 $day || croak "Day required.\n";
28 $month ||= $self->month;
29 $year ||= $self->year;
30 my $dt = $self->_new_dt($year, $month, $day);
35 my($self, $day, $month, $year) = @_;
36 $day || croak "Day required.\n";
37 $month ||= $self->month;
38 $year ||= $self->year;
39 my $dt = $self->_new_dt($year, $month, $day);
44 my($self, $delta, $day, $month, $year) = @_;
45 $delta || croak "Delta (in days) required.\n";
46 $day || croak "Day required.\n";
47 $month ||= $self->month;
48 $year ||= $self->year;
49 my $dt = $self->_new_dt($year, $month, $day);
50 $dt->add(days => $delta);
51 ($dt->day, $dt->month, $dt->year);
55 my($self, $day, $month, $year) = @_;
56 $day || croak "Day required.\n";
57 $month ||= $self->month;
58 $year ||= $self->year;
59 my $dt = $self->_new_dt($year, $month, $day);
60 # returns ($year, $week)
66 my($year, $month, $day) = @_;
67 $year or croak "year and month required\n";
68 my %parms = (year => $year);
69 $parms{month} = $month if $month;
70 $parms{day} = $day if $day;
74 DateTime->new(%parms);
79 my($year, $month) = @_;
80 $year && $month or croak "Year and month required.\n";
81 DateTime->last_day_of_month(year => $year, month => $month);