From 55cfaa5a4d4fbe197b212cc325798c055c6525ea Mon Sep 17 00:00:00 2001 From: JT Smith Date: Tue, 10 Dec 2002 04:37:28 +0000 Subject: [PATCH] fixed bug 650133 --- lib/WebGUI/DateTime.pm | 21 +++++++++++++++++++++ lib/WebGUI/Wobject/EventsCalendar.pm | 4 +++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/WebGUI/DateTime.pm b/lib/WebGUI/DateTime.pm index f88dc0164..f4f14b47b 100644 --- a/lib/WebGUI/DateTime.pm +++ b/lib/WebGUI/DateTime.pm @@ -35,6 +35,7 @@ our @EXPORT = qw(&localtime &time &addToTime &addToDate &epochToHuman &epochToSe use WebGUI::DateTime; $epoch = WebGUI::DateTime::addToDate($epoch, $years, $months, $days); $epoch = WebGUI::DateTime::addToTime($epoch, $hours, $minutes, $seconds); + ($startEpoch, $endEpoch) = WebGUI::DateTime::dayStartEnd($epoch); $dateString = WebGUI::DateTime::epochToHuman($epoch, $formatString); $setString = WebGUI::DateTime::epochToSet($epoch); $day = WebGUI::DateTime::getDayName($dayInteger); @@ -127,6 +128,26 @@ sub addToTime { #------------------------------------------------------------------- +=head2 dayStartEnd ( epoch ) + + Returns the epoch dates for the start and end of the day. + +=item epoch + + The number of seconds since January 1, 1970. + +=cut + +sub dayStartEnd { + my ($year,$month,$day, $hour,$min,$sec, $start, $end); + ($year,$month,$day, $hour,$min,$sec) = Date::Calc::Time_to_Date($_[0]); + $start = Date::Calc::Date_to_Time($year,$month,$day,0,0,0)-43200; + $end = Date::Calc::Date_to_Time($year,$month,$day,23,59,59); + return ($start, $end); +} + +#------------------------------------------------------------------- + =head2 epochToHuman ( [ epoch, format ] ) Returns a formated date string. diff --git a/lib/WebGUI/Wobject/EventsCalendar.pm b/lib/WebGUI/Wobject/EventsCalendar.pm index 67c2e790f..22eecd1eb 100644 --- a/lib/WebGUI/Wobject/EventsCalendar.pm +++ b/lib/WebGUI/Wobject/EventsCalendar.pm @@ -409,7 +409,7 @@ sub www_editEventSave { #------------------------------------------------------------------- sub www_view { - my (%var, $sameDate, $p, @list, $date, $flag, %previous, @row, $i, $maxDate, $minDate); + my (%var, $junk, $sameDate, $p, @list, $date, $flag, %previous, @row, $i, $maxDate, $minDate); tie %previous, 'Tie::CPHash'; $var{"addevent.url"} = WebGUI::URL::page('func=editEvent&eid=new&wid='.$_[0]->get("wobjectId")); $var{"addevent.label"} = WebGUI::International::get(20,$namespace); @@ -418,6 +418,7 @@ sub www_view { where wobjectId=".$_[0]->get("wobjectId")); } $minDate = $minDate || time(); + ($minDate,$junk) = WebGUI::DateTime::dayStartEnd($minDate); if ($_[0]->get("endMonth") eq "last") { ($maxDate) = WebGUI::SQL->quickArray("select max(endDate) from EventsCalendar_event where wobjectId=".$_[0]->get("wobjectId")); @@ -431,6 +432,7 @@ sub www_view { $maxDate = WebGUI::DateTime::addToDate($minDate,0,3,0); } $maxDate = $maxDate || time(); + ($junk,$maxDate) = WebGUI::DateTime::dayStartEnd($maxDate); my $monthCount = WebGUI::DateTime::monthCount($minDate,$maxDate); unless ($session{form}{pn}) { $flag = 1;