From: Jan Schneider Date: Thu, 5 Aug 2010 13:06:56 +0000 (+0200) Subject: Add toiCalendar(). X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=7fc6791f3784f52de4bf40f7ea15460e530801e5;p=horde.git Add toiCalendar(). --- diff --git a/framework/Date/lib/Horde/Date.php b/framework/Date/lib/Horde/Date.php index 12468c730..5ef2f207a 100644 --- a/framework/Date/lib/Horde/Date.php +++ b/framework/Date/lib/Horde/Date.php @@ -823,7 +823,25 @@ class Horde_Date } /** - * Format time using the specifiers available in date() or in the DateTime + * Formats date and time to the RFC 2445 iCalendar DATE-TIME format. + * + * @param boolean $floating Whether to return a floating date-time + * (without time zone information). + * + * @return string Date and time. + */ + public function toiCalendar($floating = false) + { + if ($floating) { + return $this->format('Ymd\THis'); + } + $dateTime = $this->toDateTime(); + $dateTime->setTimezone(new DateTimeZone('UTC')); + return $dateTime->format('Ymd\THis\Z'); + } + + /** + * Formats time using the specifiers available in date() or in the DateTime * class' format() method. * * To format in languages other than English, use strftime() instead.