summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schneider2011-02-28 13:52:30 +0000
committerChristian Schneider2011-02-28 13:52:30 +0000
commitdaed6196559143aaf8ccae624ad5a0fc86f39140 (patch)
tree70ca1fca681f7201038d444f91a1939bd2ef24a2
parent49370a62c09c1615b422c491d59258b810a5b4a0 (diff)
downloaditools-daed6196559143aaf8ccae624ad5a0fc86f39140.tar.gz
itools-daed6196559143aaf8ccae624ad5a0fc86f39140.tar.bz2
itools-daed6196559143aaf8ccae624ad5a0fc86f39140.zip
Added support for icsdate and icsdatetime formats in it::date()
-rw-r--r--it.class17
1 files changed, 14 insertions, 3 deletions
diff --git a/it.class b/it.class
index c8d3c29..cc7650b 100644
--- a/it.class
+++ b/it.class
@@ -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);
}