X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=src%2FHelper%2FDate.php;h=bc60cc4869de6265ac1973ff9e34504622da23a6;hb=537abd434045577958c4b3e2ce77f71358c3341c;hp=f97f52cdbe60c691d9e91d97bf2dcf34c60da12b;hpb=bd4048215800186db5224ea04e0d45cab97c12b9;p=plcapi.git diff --git a/src/Helper/Date.php b/src/Helper/Date.php index f97f52c..bc60cc4 100644 --- a/src/Helper/Date.php +++ b/src/Helper/Date.php @@ -7,15 +7,13 @@ class Date /** * Given a timestamp, return the corresponding ISO8601 encoded string. * - * Really, timezones ought to be supported - * but the XML-RPC spec says: + * Really, timezones ought to be supported but the XML-RPC spec says: * - * "Don't assume a timezone. It should be specified by the server in its - * documentation what assumptions it makes about timezones." + * "Don't assume a timezone. It should be specified by the server in its documentation what assumptions it makes + * about timezones." * - * These routines always assume localtime unless - * $utc is set to 1, in which case UTC is assumed - * and an adjustment for locale is made when encoding + * These routines always assume localtime unless $utc is set to 1, in which case UTC is assumed and an adjustment + * for locale is made when encoding * * @param int $timet (timestamp) * @param int $utc (0 or 1) @@ -28,8 +26,7 @@ class Date $t = strftime("%Y%m%dT%H:%M:%S", $timet); } else { if (function_exists('gmstrftime')) { - // gmstrftime doesn't exist in some versions - // of PHP + // gmstrftime doesn't exist in some versions of PHP $t = gmstrftime("%Y%m%dT%H:%M:%S", $timet); } else { $t = strftime("%Y%m%dT%H:%M:%S", $timet - date('Z')); @@ -50,7 +47,7 @@ class Date public static function iso8601Decode($idate, $utc = 0) { $t = 0; - if (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})/', $idate, $regs)) { + if (preg_match('/([0-9]{4})([0-1][0-9])([0-3][0-9])T([0-2][0-9]):([0-5][0-9]):([0-5][0-9])/', $idate, $regs)) { if ($utc) { $t = gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); } else {