TimeZone.php
authorleon <leon@roojs.com>
Fri, 27 Oct 2023 07:17:57 +0000 (15:17 +0800)
committerleon <leon@roojs.com>
Fri, 27 Oct 2023 07:17:57 +0000 (15:17 +0800)
TimeZone.php

index ff141ca..a7c5927 100644 (file)
@@ -123,30 +123,42 @@ class Pman_Core_TimeZone extends Pman
     static function toRegion($tz)
     {
         if(!self::isValidTimeZone($tz)) {
-            return false;
+            return '';
         }
         return explode('/', $tz)[0];
     }
 
     static function toArea($tz)
     {
+        if(!self::isValidTimeZone($tz)) {
+            return '';
+        }
         return explode('/', $tz)[1];
     }
     
     static function toTimeOffset($dt, $tz)
     {
+        if(!self::isValidTimeZone($tz)) {
+            return '';
+        }
         $date = new DateTime($dt, new DateTimeZone($tz));
         return $date->format('P');
     }
 
     static function toDisplayArea($dt, $tz)
     {
+        if(!self::isValidTimeZone($tz)) {
+            return '';
+        }
         return str_replace('_', ' ', self::toArea($tz)) . ' (GMT ' . self::toTimeOffset($dt,$tz) . ')';
 
     }
 
     static function toDisplayName($dt, $tz)
     {
+        if(!self::isValidTimeZone($tz)) {
+            return '';
+        }
         return self::toRegion($tz) . '/' . self::toDisplayArea($dt, $tz);
     }
 }
\ No newline at end of file