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::$timezones as $tz => $o) {
24 if(!empty($_REQUEST['region']) && $_REQUEST['region'] != $o['region']) {
29 !empty($_REQUEST['query']['area_start'])
31 substr(strtolower($o['area']), 0, strlen($_REQUEST['query']['area_start'])) != strtolower($_REQUEST['query']['area_start'])
36 'region' => $o['region'],
38 'displayArea' => $o['displayArea']
42 echo json_encode(array(
46 'successProperty' => 'success',
47 'totalProperty' => 'total',
55 'total' => count($data),
61 function post($base) {
65 static $timezones = array();
67 static function getTimezones()
69 if(!empty(self::$timezones)) {
70 return self::$timezones;
73 $ce = DB_DataObject::factory('core_enum');
76 *, TIME_FORMAT(TIMEDIFF(NOW(), CONVERT_TZ(NOW(), Name, "UTC")), "%H:%i") as timeOffset
85 // ignroe timezone such as 'CET' and 'America/Argentina/Buenos_Aires'
86 if(substr_count($ce->Name, '/') != 1) {
90 $ar = explode('/', $ce->Name);
91 // ignore timezone such as 'Etc/GMT+8'
96 $displayOffset = '(GMT ' . ((substr($ce->timeOffset, 0, 1) == '-') ? '' : '+') . $ce->timeOffset . ')';
97 $offsetAr = explode(':', $ce->timeOffset);
100 self::$timezones[$ce->Name] = array(
103 'displayName' => $ce->Name . ' ' . $displayOffset,
104 'displayArea' => $ar[1] . ' ' . $displayOffset,
105 'decimalOffset' => ($offsetAr[0] . ($offsetAr[1] / 60))
109 return self::$timezones;