Import/Timezone.php
authorleon <leon@roojs.com>
Mon, 15 Apr 2024 03:06:17 +0000 (11:06 +0800)
committerleon <leon@roojs.com>
Mon, 15 Apr 2024 03:06:17 +0000 (11:06 +0800)
Import/Timezone.php [new file with mode: 0644]

diff --git a/Import/Timezone.php b/Import/Timezone.php
new file mode 100644 (file)
index 0000000..48f9be4
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+
+
+
+require_once 'Pman.php';
+
+class Pman_Core_Import_Timezone extends Pman 
+{
+    static $cli_desc = "Import timezone region name and area name to core_enum"; 
+    
+    static $cli_opts = array();
+
+    function getAuth()
+    {
+        $ff = HTML_FlexyFramework::get();
+        
+        if (!$ff->cli) {
+            die("cli only");
+        }
+    }
+    
+    function get($part = '', $opts=array())
+    {
+        $ce = DB_DataObject::factory('core_enum');
+        $ce->query("
+            SELECT
+                *, TIME_FORMAT(TIMEDIFF(NOW(), CONVERT_TZ(NOW(), Name, 'UTC')), '%H:%i') as timeOffset
+            FROM
+                mysql.time_zone_name
+            WHERE
+                Name LIKE '%/%'
+                AND
+                Name NOT LIKE '%/%/%'
+                AND
+                Name NOT LIKE 'right%'
+                AND
+                Name NOT LIKE 'posix%'
+                AND
+                Name NOT LIKE 'Etc%'
+            ORDER BY
+                SUBSTRING_INDEX(Name, '/', 1) ASC,
+                timeoffset ASC,
+                Name ASC
+        ");
+
+        $values = array();
+
+        while($ce->fetch()) {
+            $ar = explode('/', $ce->Name);
+            $region = $ar[0];
+            $area = $ar[1];
+
+            
+        }
+    }
+}
\ No newline at end of file