From f0d2ec3481d1d4edf14b163699a5ec0908332503 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sat, 3 Dec 2005 23:41:00 +0000 Subject: [PATCH] more time zone problems --- lib/WebGUI/DateTime.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/WebGUI/DateTime.pm b/lib/WebGUI/DateTime.pm index caee1bf83..4cc5968ab 100644 --- a/lib/WebGUI/DateTime.pm +++ b/lib/WebGUI/DateTime.pm @@ -207,7 +207,7 @@ sub epochToHuman { my $locale = $language->{languageAbbreviation} || "en"; $locale .= "_".$language->{locale} if ($language->{locale}); my $timeZone = $session{user}{timeZone} || "America/Chicago"; - my $dt = DateTime->from_epoch( epoch=>shift||time(), time_zone=>$timeZone, locale=>$locale ); + my $dt = DateTime->from_epoch( epoch=>shift||time(), time_zone=>$timeZone, locale=>$locale ); my $output = shift || "%z %Z"; my $temp; #---date format preference @@ -268,7 +268,8 @@ A boolean indicating that the time should be added to the output, thust turning =cut sub epochToSet { - my $dt = DateTime->from_epoch( epoch =>shift, time_zone=>$session{user}{timeZone}); + my $timeZone = $session{user}{timeZone} || "America/Chicago"; + my $dt = DateTime->from_epoch( epoch =>shift, time_zone=>$timeZone); my $withTime = shift; if ($withTime) { return $dt->strftime("%Y-%m-%d %H:%M:%S"); @@ -658,7 +659,7 @@ sub setToEpoch { $dt = $parser->parse_datetime($set); } # in epochToSet we apply the user's time zone, so now we have to remove it. - $dt->set_time_zone($session{user}{timeZone}); # assign the user's timezone + $dt->set_time_zone($session{user}{timeZone}|| "America/Chicago"); # assign the user's timezone # my $u = WebGUI::User->new(1); # $dt->set_time_zone($u->profileField("timeZone")); # convert to the visitor's or default time zone return $dt->epoch;