2 require_once 'Pman.php';
4 class Pman_Core_TimeZone extends Pman
10 if (!$this->getAuthUser()) {
11 $this->jerr("Not authenticated", array('authFailure' => true));
17 function get($base, $opts=array())
23 foreach(self::$offsets as $tz => $o) {
24 $arr = explode('/', $tz);
26 if(!empty($_REQUEST['region']) && $_REQUEST['region'] != $arr[0]) {
30 if(!empty($_REQUEST['query']['area_start'])){
36 'displayArea' => self::getDisplayArea($tz)
40 echo json_encode(array(
44 'successProperty' => 'success',
45 'totalProperty' => 'total',
54 'total' => count($data),
60 function post($base) {
64 static $offsets = array();
66 static function getOffsets()
68 if(!empty(self::$offsets)) {
69 return self::$offsets;
72 $ce = DB_DataObject::factory('core_enum');
75 *, TIME_FORMAT(TIMEDIFF(NOW(), CONVERT_TZ(NOW(), Name, "UTC")), "%H:%i") as offset
84 // ignroe timezone such as 'CET' and 'America/Argentina/Buenos_Aires'
85 if(substr_count($ce->Name, '/') != 1) {
89 $ar = explode('/', $ce->Name);
90 // ignore timezone such as 'Etc/GMT+8'
95 self::$offsets[$ce->Name] = substr($ce->offset, 0, 1) == '-' ? $ce->offset : '+' . $ce->offset;
98 return self::$offsets;
101 static function getDisplayArea($timezone)
106 if(!isset(self::$offsets[$timezone])) {
110 $ar = explode('/', $timezone);
112 // e.g. 'Hong_Kong (GMT +08:00)'
113 return $ar[1] . ' (GMT ' . self::$offsets[$timezone] . ')';