From: pdontthink Date: Tue, 6 Dec 2022 11:42:23 +0000 (+0000) Subject: Fix poorly written timezone parsing X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=4acc9018d08d36af8506ae5bab89647e66c53658;p=squirrelmail.git Fix poorly written timezone parsing git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@14979 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/date.php b/functions/date.php index 7e9f7484..c22e54f6 100644 --- a/functions/date.php +++ b/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 */