Bläddra i källkod

Merge branch 'trunk'

Andy 2 år sedan
förälder
incheckning
aa760dcad7
1 ändrade filer med 9 tillägg och 6 borttagningar
  1. 9 6
      functions/date.php

+ 9 - 6
functions/date.php

@@ -83,13 +83,16 @@ function getGMTSeconds($stamp, $tzc) {
             break;
     }
     $neg = false;
-    if (substr($tzc, 0, 1) == '-') {
-        $neg = true;
-    } else if (substr($tzc, 0, 1) != '+') {
-        $tzc = '+'.$tzc;
+    if (preg_match('/^([+-]?)(\d\d)(\d\d)$/', $tzc, $matches)) {
+        if ($matches[1] === '-')
+            $neg = true;
+        $hh = $matches[2];
+        $mm = $matches[3];
+    } else {
+        // anything not listed above and not in the form +0400
+        // defaults to UTC
+        $hh = $mm = 0;
     }
-    $hh = substr($tzc,1,2);
-    $mm = substr($tzc,3,2);
     $iTzc = ($hh * 60 + $mm) * 60;
     if ($neg) $iTzc = -1 * (int) $iTzc;
     /* stamp in gmt */