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::$tiemzones 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'],
37 'displayArea' => $o['displayArea']
41 echo json_encode(array(
45 'successProperty' => 'success',
46 'totalProperty' => 'total',
53 'total' => count($data),
59 function post($base) {
63 static $timezones = array();
65 static function getTimezones()
67 if(!empty(self::$timezones)) {
68 return self::$timezones;
71 $ce = DB_DataObject::factory('core_enum');
74 *, TIME_FORMAT(TIMEDIFF(NOW(), CONVERT_TZ(NOW(), Name, "UTC")), "%H:%i") as timeOffset
83 // ignroe timezone such as 'CET' and 'America/Argentina/Buenos_Aires'
84 if(substr_count($ce->Name, '/') != 1) {
88 $ar = explode('/', $ce->Name);
89 // ignore timezone such as 'Etc/GMT+8'
94 $displayOffset = '(GMT ' . ((substr($ce->timeOffset, 0, 1) == '-') ? '' : '+') . $ce->timeOffset . ')';
95 $offsetAr = explode(':', $ce->timeOffset);
98 self::$timezones[$ce->Name] = array(
101 'displayName' => $ce->Name . ' ' . $displayOffset,
102 'displayArea' => $ar[1] . ' ' . $displayOffset
106 return self::$timezones;