diff options
author | Christian Schneider | 2011-02-28 13:52:30 +0000 |
---|---|---|
committer | Christian Schneider | 2011-02-28 13:52:30 +0000 |
commit | daed6196559143aaf8ccae624ad5a0fc86f39140 (patch) | |
tree | 70ca1fca681f7201038d444f91a1939bd2ef24a2 /it.class | |
parent | 49370a62c09c1615b422c491d59258b810a5b4a0 (diff) | |
download | itools-daed6196559143aaf8ccae624ad5a0fc86f39140.tar.gz itools-daed6196559143aaf8ccae624ad5a0fc86f39140.tar.bz2 itools-daed6196559143aaf8ccae624ad5a0fc86f39140.zip |
Added support for icsdate and icsdatetime formats in it::date()
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); } |