CC-5627 : Check all Application_Common_DateHelper calculations that use timezone.
This commit is contained in:
parent
3d1f0b0d0e
commit
b13d12eaac
4 changed files with 41 additions and 32 deletions
|
@ -45,6 +45,22 @@ class Application_Common_DateHelper
|
|||
return gmdate("H:i:s", $this->_dateTime);
|
||||
}
|
||||
|
||||
public static function getUserTimezoneOffset()
|
||||
{
|
||||
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
|
||||
$now = new DateTime("now", $userTimezone);
|
||||
|
||||
return $now->format("Z");
|
||||
}
|
||||
|
||||
public static function getStationTimezoneOffset()
|
||||
{
|
||||
$stationTimezone = new DateTimeZone(Application_Model_Preference::GetDefaultTimezone());
|
||||
$now = new DateTime("now", $stationTimezone);
|
||||
|
||||
return $now->format("Z");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DateTime - YYYY-MM-DD 00:00 in station timezone of today
|
||||
|
@ -374,6 +390,21 @@ class Application_Common_DateHelper
|
|||
return $d->format($format);
|
||||
}
|
||||
|
||||
/*
|
||||
* @param $datetime string Y-m-d H:i:s in user timezone
|
||||
*
|
||||
* @return string Y-m-d H:i:s in UTC timezone
|
||||
*/
|
||||
public static function UserTimezoneStringToUTCString($datetime, $format="Y-m-d H:i:s") {
|
||||
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
|
||||
$utcTimezone = new DateTimeZone("UTC");
|
||||
|
||||
$d = new DateTime($datetime, $userTimezone);
|
||||
$d->setTimezone($utcTimezone);
|
||||
|
||||
return $d->format($format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the columns given in the array $columnsToConvert in the
|
||||
* database result $rows to local timezone.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue