[Rt-commit] r11920 - in rt/branches/3.8-TESTING: . html/NoAuth/iCal sbin

alexmv at bestpractical.com alexmv at bestpractical.com
Mon Apr 28 15:46:44 EDT 2008


Author: alexmv
Date: Mon Apr 28 15:46:43 2008
New Revision: 11920

Modified:
   rt/branches/3.8-TESTING/   (props changed)
   rt/branches/3.8-TESTING/html/NoAuth/iCal/dhandler
   rt/branches/3.8-TESTING/lib/RT/Date.pm
   rt/branches/3.8-TESTING/sbin/rt-test-dependencies.in

Log:
 r31006 at kohr-ah:  chmrr | 2008-04-28 15:46:36 -0400
  * Remove Date::ICal dep by doing it ourselves


Modified: rt/branches/3.8-TESTING/html/NoAuth/iCal/dhandler
==============================================================================
--- rt/branches/3.8-TESTING/html/NoAuth/iCal/dhandler	(original)
+++ rt/branches/3.8-TESTING/html/NoAuth/iCal/dhandler	Mon Apr 28 15:46:43 2008
@@ -48,7 +48,6 @@
 <%init>
 use Data::ICal;
 use Data::ICal::Entry::Event;
-use Date::ICal;
 use Encode ();
 
 my $path = $m->dhandler_arg;
@@ -88,42 +87,31 @@
 $feed->add_properties('method'   => ['publish']);
 $feed->add_properties('prodid'   => ["-//$RT::rtname//"]);
 
-my $ic = sub {
-    my $time = shift;
-
-    if (ref $time) {
-        $time = Date::ICal->new( epoch => $time->Unix )->ical;
-    } else {
-        $time = Date::ICal->new( epoch => $time )->ical;
-    }
-    $time =~ s/T.*// if shift;
-    return $time;
-};
-
 while (my $t = $tickets->Next) {
     next unless $t->DueObj->Unix > 0;
 
     my $starttime = $t->StartsObj->Unix > 0 ? $t->StartsObj : $t->CreatedObj;
 
+    my $now = RT::Date->new; $now->SetToNow;
     my $start = Data::ICal::Entry::Event->new;
     my $end   = Data::ICal::Entry::Event->new;
     $_->add_properties(
         url       => $RT::WebURL . "?q=".$t->id,
         organizer => $t->OwnerObj->Name,
-        dtstamp   => $ic->(time),
-        created   => $ic->($t->CreatedObj),
-       'last-modified' => $ic->($t->LastUpdatedObj),
+        dtstamp   => $now->iCal,
+        created   => $t->CreatedObj->iCal,
+       'last-modified' => $t->LastUpdatedObj->iCal,
     ) for $start, $end;
 
     $start->add_properties(
         summary   => "Start: ".$t->Subject,
-        dtstart   => $ic->($starttime, 1),
-        dtend     => $ic->($starttime, 1),
+        dtstart   => $starttime->iCalDate,
+        dtend     => $starttime->iCalDate,
     );
     $end->add_properties(
         summary   => "Due: ".$t->Subject,
-        dtstart   => $ic->($t->DueObj, 1),
-        dtend     => $ic->($t->DueObj, 1),
+        dtstart   => $t->DueObj->iCalDate,
+        dtend     => $t->DueObj->iCalDate,
     );
 
     $feed->add_entry($start);

Modified: rt/branches/3.8-TESTING/lib/RT/Date.pm
==============================================================================
--- rt/branches/3.8-TESTING/lib/RT/Date.pm	(original)
+++ rt/branches/3.8-TESTING/lib/RT/Date.pm	Mon Apr 28 15:46:43 2008
@@ -740,6 +740,34 @@
     return $res;
 }
 
+=head4 iCal
+
+Returns the date and time formatted as an ICalendar string -- that is,
+C<yyyymmddThhmmssZ>
+
+=cut
+
+sub iCal {
+    my $self = shift;
+    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
+
+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 );
+}
+
 sub _SplitOffset {
     my ($self, $offset) = @_;
     my $sign = $offset < 0? '-': '+';

Modified: rt/branches/3.8-TESTING/sbin/rt-test-dependencies.in
==============================================================================
--- rt/branches/3.8-TESTING/sbin/rt-test-dependencies.in	(original)
+++ rt/branches/3.8-TESTING/sbin/rt-test-dependencies.in	Mon Apr 28 15:46:43 2008
@@ -333,7 +333,6 @@
 .
 
 $deps{'ICAL'} = [ text_to_hash( << '.') ];
-Date::ICal
 Data::ICal
 .
 


More information about the Rt-commit mailing list