First, the regex in the second preg_match looks like it should be catching strings in MySQL Datetime format and if you make a change in the whitespace match it does:
Code: Select all
- if (preg_match("~(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(.*)~",$date,$matches))
+ if (preg_match("~(\\d{4})-(\\d{2})-(\\d{2})[T\s](\\d{2}):(\\d{2}):(\\d{2})(.*)~",$date,$matches))
http://bugs.php.net/bug.php?id=30096
The thread says the bug has been fixed, in fact it is in the changlog for PHP 5.1.0
http://www.php.net/ChangeLog-5.php
but with previous versions of PHP gmmktime will not be correct.
Is gmmktime even the right function to be using here? That function accepts a GM Date and returns a Unix time in the server local time. I think JDate is supposed to set it's $_date property to a GM Time which means it should be changed this way...
Code: Select all
- $this->_date = gmmktime($matches[4],$matches[5],$matches[6],$matches[2],$matches[3],$matches[1]);
+ $this->_date = mktime($matches[4],$matches[5],$matches[6],$matches[2],$matches[3],$matches[1]) - $this->serverOffset();