X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=1.18%2Flib%2FHTML%2FCalendarMonth%2FDateTool%2FTimeLocal.pm;fp=1.18%2Flib%2FHTML%2FCalendarMonth%2FDateTool%2FTimeLocal.pm;h=05b084eee67530e918781211ad247660a1a85bed;hb=8271142675d51730e1a96d3d184ed49069c2a68c;hp=0000000000000000000000000000000000000000;hpb=ddb50b302aac3e5b05ddd17c736ed8f58e623584;p=deb_pkgs%2Flibhtml-calendarmonth-perl.git diff --git a/1.18/lib/HTML/CalendarMonth/DateTool/TimeLocal.pm b/1.18/lib/HTML/CalendarMonth/DateTool/TimeLocal.pm new file mode 100644 index 0000000..05b084e --- /dev/null +++ b/1.18/lib/HTML/CalendarMonth/DateTool/TimeLocal.pm @@ -0,0 +1,39 @@ +package HTML::CalendarMonth::DateTool::TimeLocal; + +# Interface to Time::Local + +use strict; +use Carp; + +use vars qw(@ISA $VERSION); + +@ISA = qw(HTML::CalendarMonth::DateTool); + +$VERSION = '0.01'; + +use Time::Local; + +sub dow1st_and_lastday { + my($self, $month, $year) = @_; + $month ||= $self->month; + $year ||= $self->year; + # map month to 0-12 + --$month; + # years since 1900...hooh-rah for POSIX... + $year -= 1900; + my $nmonth = $month + 1; + my $nyear = $year; + if ($nmonth > 11) { + # Happy new year + $nmonth = 0; + ++$nyear; + } + # Leave dow of 1st in 0-based format + my $dow1st = (gmtime(Time::Local::timegm(0,0,0,1,$month,$year)))[6]; + # Last day is one day prior to 1st of month after + my $lastday = (gmtime(Time::Local::timegm(0,0,0,1,$nmonth,$nyear) + - 60*60*24))[3]; + ($dow1st, $lastday); +} + +1;