[Rt-commit] r14223 - in rt/3.8/trunk: share/html/NoAuth/iCal

ruz at bestpractical.com ruz at bestpractical.com
Thu Jul 17 13:41:04 EDT 2008


Author: ruz
Date: Thu Jul 17 13:41:03 2008
New Revision: 14223

Modified:
   rt/3.8/trunk/lib/RT/Date.pm
   rt/3.8/trunk/share/html/NoAuth/iCal/dhandler

Log:
* refactor iCal and iCalDate to match generic formatters API

Modified: rt/3.8/trunk/lib/RT/Date.pm
==============================================================================
--- rt/3.8/trunk/lib/RT/Date.pm	(original)
+++ rt/3.8/trunk/lib/RT/Date.pm	Thu Jul 17 13:41:03 2008
@@ -742,30 +742,33 @@
 
 =head4 iCal
 
-Returns the date and time formatted as an ICalendar string -- that is,
-C<yyyymmddThhmmssZ>
+Returns the object's date and time in iCalendar format,
+
+Supports arguments: C<Date> and C<Time>.
+See </Output formatters> for description of arguments.
 
 =cut
 
 sub iCal {
     my $self = shift;
+    my %args = (
+        Date => 1, Time => 1,
+        @_,
+    );
     my ($sec,$min,$hour,$mday,$mon,$year,$wday,$ydaym,$isdst,$offset) =
-                            $self->Localtime( "UTC" );
-    
-    return sprintf( '%04d%02d%02dT%02d%02d%02dZ', $year, $mon, $mday, $hour, $min, $sec );
-}
-
-=head4 iCalDate
-
-Returns the date formatted as an ICalendar string -- that is, C<yyyymmddZ>
-
-=cut
+        $self->Localtime( 'utc' );
 
-sub iCalDate {
-    my $self = shift;
-    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$ydaym,$isdst,$offset) =
-                            $self->Localtime( "UTC" );
-    return sprintf( '%04d%02d%02dZ', $year, $mon, $mday );
+    my $res;
+    if ( $args{'Date'} && !$args{'Time'} ) {
+        $res = sprintf( '%04d%02d%02dZ', $year, $mon, $mday );
+    }
+    elsif ( !$args{'Date'} && $args{'Time'} ) {
+        $res = sprintf( 'T%02d%02d%02dZ', $hour, $min, $sec );
+    }
+    else {
+        $res = sprintf( '%04d%02d%02dT%02d%02d%02dZ', $year, $mon, $mday, $hour, $min, $sec );
+    }
+    return $res;
 }
 
 sub _SplitOffset {

Modified: rt/3.8/trunk/share/html/NoAuth/iCal/dhandler
==============================================================================
--- rt/3.8/trunk/share/html/NoAuth/iCal/dhandler	(original)
+++ rt/3.8/trunk/share/html/NoAuth/iCal/dhandler	Thu Jul 17 13:41:03 2008
@@ -103,13 +103,13 @@
 
     $start->add_properties(
         summary   => "Start: ".$t->Subject,
-        dtstart   => $starttime->iCalDate,
-        dtend     => $starttime->iCalDate,
+        dtstart   => $starttime->iCal( Time => 0 ),
+        dtend     => $starttime->iCal( Time => 0 ),
     );
     $end->add_properties(
         summary   => "Due: ".$t->Subject,
-        dtstart   => $t->DueObj->iCalDate,
-        dtend     => $t->DueObj->iCalDate,
+        dtstart   => $t->DueObj->iCal( Time => 0 ),
+        dtend     => $t->DueObj->iCal( Time => 0 ),
     );
 
     $feed->add_entry($start);


More information about the Rt-commit mailing list