From 7fc6791f3784f52de4bf40f7ea15460e530801e5 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Thu, 5 Aug 2010 15:06:56 +0200 Subject: [PATCH] Add toiCalendar(). --- framework/Date/lib/Horde/Date.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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. -- 2.11.0