TimeZone.php
authorleon <leon@roojs.com>
Tue, 3 Oct 2023 02:26:10 +0000 (10:26 +0800)
committerleon <leon@roojs.com>
Tue, 3 Oct 2023 02:26:10 +0000 (10:26 +0800)
TimeZone.php

index 896d508..80bb387 100644 (file)
@@ -16,39 +16,7 @@ class Pman_Core_TimeZone extends Pman
 
     function get($base, $opts=array())
     {
-        $ce = DB_DataObject::factory('core_enum');
-        $ce->query('
-            SELECT
-                *, TIME_FORMAT(TIMEDIFF(NOW(), CONVERT_TZ(NOW(), Name, "UTC")), "%H:%i") as offset
-            FROM
-                mysql.time_zone_name
-            ORDER BY
-                offset DESC,
-                Name DESC
-        ');
-
-        $data = array();
-        while($ce->fetch()) {
-            // ignroe timezone such as 'CET' and 'America/Argentina/Buenos_Aires'
-            if(substr_count($ce->Name, '/') != 1) {
-                continue;
-            }
-            $ar = explode('/', $ce->Name);
-            // ignore timezone such as 'Etc/GMT+8'
-            if($ar[0] == 'Etc') {
-                continue;
-            }
-
-            if(!empty($_REQUEST['region']) && $ar[0] != $_REQUEST['region']) {
-                continue;
-            }
-
-            $data[] = array(
-                'region' => $ar[0],
-                'area' => $ar[1],
-                'offset' => $ce->offset
-            );
-        }
+        $data = self::getTimezones();
 
         echo json_encode(array(
             'data' => $data,