1 package HTML::CalendarMonth::DateTool::Cal;
3 $HTML::CalendarMonth::DateTool::Cal::VERSION = '1.25';
6 # Interface to unix 'cal' command
12 use base qw( HTML::CalendarMonth::DateTool );
14 sub dow1st_and_lastday {
15 my($self, $month, $year) = @_;
16 $month ||= $self->month;
17 $year ||= $self->year;
18 my $cmd = $self->_cal_cmd or croak "cal command not found\n";
20 my @cal = grep(!/^\s*$/,`$cmd $month $year`);
22 my @days = grep(/\d+/,split(/\s+/,$cal[2]));
23 my $dow1st = 6 - $#days;
24 my($lastday) = $cal[$#cal] =~ /(\d+)\s*$/;
25 # With dow1st and lastday, one builds a calendar sequentially.
26 # Historically, in particular Sep 1752, days have been skipped. Here's
27 # the chance to catch that.
29 if ($month == 9 && $year == 1752) {
31 grep(++$skips{$_}, 3 .. 13);
32 $self->_skips(\%skips);