diff options
Diffstat (limited to 'it.class')
-rw-r--r-- | it.class | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -691,11 +691,14 @@ static function gets() * @param format optional format (default is 2007-01-02 03:04:05). * Other formats are "date", "datetime", "time". * Formats can be qualified with language, e.g. "date:en" + * Special formats without language support are "icsdate", "icsdatetime". * @param stamp optional unix timestamp (default is now). * If it contains nondigits, it is fed to strtotime */ static function date($format = "", $stamp = null) { + $stamp = !isset($stamp) ? time() : (it::match('^\d+$', $stamp) ? $stamp : strtotime($stamp)); + list($name, $language) = explode(":", $format); if ($format && !$language) @@ -712,9 +715,17 @@ static function date($format = "", $stamp = null) ); if (!($formatstring = $formats["$name:$language"]) && !($formatstring = $formats[$name])) - $formatstring = $format; - - $stamp = !isset($stamp) ? time() : (it::match('^\d+$', $stamp) ? $stamp : strtotime($stamp)); + { + if (it::match('^icsdate', $format)) # Special icsdate or icsdatetime format? Use UTC time format for Google Calendar to be happy + { + if ($format == "icsdate") + return date("Ymd", $stamp) . "Z"; # MUST NOT use gmdate! + else + return gmdate("Ymd", $stamp) . "T" . gmdate("His", $stamp) . "Z"; + } + else + $formatstring = $format; + } return date($formatstring, $stamp); } |