adding epochToArray to EventsCalendar.pm as a kludge b/c it's no longer in DateTime.pm.
This commit is contained in:
parent
f6d36f47ec
commit
eb9d4ba546
1 changed files with 25 additions and 4 deletions
|
|
@ -83,6 +83,27 @@ sub definition {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 epochToArray ( epoch )
|
||||
|
||||
Returns an array date.
|
||||
|
||||
=head3 epoch
|
||||
|
||||
The number of seconds since January 1, 1970.
|
||||
|
||||
=cut
|
||||
|
||||
sub epochToArray {
|
||||
my $timeZone = $session{user}{timeZone} || "America/Chicago";
|
||||
use DateTime;
|
||||
my $dt = DateTime->from_epoch( epoch =>shift, time_zone=>$timeZone);
|
||||
my @date = split / /, $dt->strftime("%Y %m %d %H %M %S");
|
||||
@date = map {$_ += 0} @date;
|
||||
return @date;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -232,7 +253,7 @@ sub view {
|
|||
$maxDate = WebGUI::DateTime::addToDate($minDate,0,1,0);
|
||||
}
|
||||
#WebGUI::ErrorHandler::warn("calMonthStart:".$calMonthStart." calMonthEnd:".$calMonthEnd);
|
||||
my @now = WebGUI::DateTime::epochToArray(WebGUI::DateTime::time());
|
||||
my @now = epochToArray(WebGUI::DateTime::time());
|
||||
my $calHasEvent = 0;
|
||||
#monthcount minus i is the number of months remaining to be processed.
|
||||
for (my $i=$calMonthStart;$i<=$calMonthEnd;$i++) {
|
||||
|
|
@ -240,7 +261,7 @@ sub view {
|
|||
my $monthHasEvent = 0;
|
||||
my $thisMonth = WebGUI::DateTime::addToDate($minDate,0,($i-1),0);
|
||||
my ($monthStart, $monthEnd) = WebGUI::DateTime::monthStartEnd($thisMonth);
|
||||
my @thisMonthDate = WebGUI::DateTime::epochToArray($thisMonth);
|
||||
my @thisMonthDate = epochToArray($thisMonth);
|
||||
#Check month to see if it is in the allowed month range. End loop if it's not.
|
||||
if ($thisMonth > $maxDate) {
|
||||
$i = $calMonthEnd;
|
||||
|
|
@ -279,7 +300,7 @@ sub view {
|
|||
#cycle through each day in the event, pushing the event's day listing into the proper day.
|
||||
for (my $i=$eventCycleStart; $i<=$eventCycleStop; $i++) {
|
||||
#create an array for the specific day in the event.
|
||||
my @date = WebGUI::DateTime::epochToArray(WebGUI::DateTime::addToDate($eventStartDate,0,0,$i));
|
||||
my @date = epochToArray(WebGUI::DateTime::addToDate($eventStartDate,0,0,$i));
|
||||
# if the event goes past the end of this month, halt the loop.
|
||||
# No need to continue processing days that aren't in this month.
|
||||
if ($monthEnd < (WebGUI::DateTime::addToDate($eventStartDate,0,0,$i) - 1)) {
|
||||
|
|
@ -341,7 +362,7 @@ sub view {
|
|||
});
|
||||
$dayOfWeekCounter++;
|
||||
}
|
||||
my @date = WebGUI::DateTime::epochToArray($thisMonth);
|
||||
my @date = epochToArray($thisMonth);
|
||||
my @dayloop;
|
||||
for (my $dayCounter=1; $dayCounter <= $daysInMonth; $dayCounter++) {
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue