add Timezone
[Pman.Core] / TimeZone.php
index c0e459e..69a3e57 100644 (file)
@@ -20,7 +20,7 @@ class Pman_Core_TimeZone extends Pman
 
         $data = array();
 
-        foreach(self::$tiemzones as $tz => $o) {
+        foreach(self::$timezones as $tz => $o) {
             if(!empty($_REQUEST['region']) && $_REQUEST['region'] != $o['region']) {
                 continue;
             }
@@ -34,6 +34,7 @@ class Pman_Core_TimeZone extends Pman
             }
             $data[] = array(
                 'region' => $o['region'],
+                'area' => $o['area'],
                 'displayArea' => $o['displayArea']
             );
         }
@@ -46,6 +47,7 @@ class Pman_Core_TimeZone extends Pman
                 'totalProperty' => 'total',
                 'fields' => array(
                     'region',
+                    'area',
                     'displayArea'
                 )
             ),
@@ -69,15 +71,19 @@ class Pman_Core_TimeZone extends Pman
         }
 
         $ce = DB_DataObject::factory('core_enum');
-        $ce->query('
+        $ce->query("
             SELECT
-                *, TIME_FORMAT(TIMEDIFF(NOW(), CONVERT_TZ(NOW(), Name, "UTC")), "%H:%i") as timeOffset
+                *, TIME_FORMAT(TIMEDIFF(NOW(), CONVERT_TZ(NOW(), Name, 'UTC')), '%H:%i') as timeOffset
             FROM
                 mysql.time_zone_name
+            WHERE
+                Name NOT LIKE '%/%'
+                AND
+                NAME NOT LIKE 'Etc%'
             ORDER BY
                 timeoffset DESC,
                 Name DESC
-        ');
+        ");
 
         while($ce->fetch()) {
             // ignroe timezone such as 'CET' and 'America/Argentina/Buenos_Aires'
@@ -91,15 +97,17 @@ class Pman_Core_TimeZone extends Pman
                 continue;
             }
 
-            $displayOffset = '(GMT ' . ((substr($ce->timeOffset, 0, 1) == '-') ? '' : '+') . $ce->timeOffset . ')';
+            $displayArea = str_replace('_', ' ', $ar[1]);
 
-            die($displayOffset);
+            $timeOffset = ((substr($ce->timeOffset, 0, 1) == '-') ? '' : '+') . $ce->timeOffset;
+            $displayOffset = '(GMT ' . $timeOffset . ')';
 
             self::$timezones[$ce->Name] = array(
                 'region' => $ar[0],
                 'area' => $ar[1],
-                'displayName' => $ce->Name . ' ' . $displayOffset,
-                'displayArea' => $ar[1] . ' ' . $displayOffset
+                'displayName' => $ar[0] . '/' . $displayArea . ' ' . $displayOffset,
+                'displayArea' => $displayArea . ' ' . $displayOffset,
+                'timeOffset' => $timeOffset
             );
         }