On Thu, 20 Mar 2003, fglock wrote:

> I implemented Date::ICal offsets using DateTime::Timezone,
> but I'm getting some errors that I can't figure out why.
>
> Only a few tests fail, and I can't make sense of it.
>
> These errors might indicate that either Date::ICal, or
> DateTime::Timezone, or me, are doing something wrong.
> I'd appreciate if somebody could give some advice.

Ok, below is a patch which fixes some bugs and a does a little cleanup.

There's no point in setting $self->{dt} inside add(), since all you're
doing is setting it to the same object as before.

The bug I found was in the ical() method.  If you call set_time_zone(),
the object's local time is adjusted internally, so you don't want to then
go and try to adjust it yourself, or it ends up being adjusted twice over.
However, this seems to have created some other test failures.  I think
this is probably a bug in the offset() method, _or_ in the test's
expectations.  I'm not sure.

[EMAIL PROTECTED]:~/Date-ICal-2.05$ diff -ru ../Date-ICal-2.05.clean/ .
diff -ru ../Date-ICal-2.05.clean/lib/Date/ICal.pm ./lib/Date/ICal.pm
--- ../Date-ICal-2.05.clean/lib/Date/ICal.pm    2003-03-20 15:38:31.000000000 -0600
+++ ./lib/Date/ICal.pm  2003-03-20 15:56:05.000000000 -0600
@@ -305,9 +305,7 @@
         # form, we'll need to adjust it for output

         my $self = $self->clone;
-        my $seconds = $self->{dt}->time_zone->offset_for_datetime( $self->{dt} );
         $self->{dt}->set_time_zone( 'UTC' );
-        $self->{dt}->add( seconds => -1 * $seconds );

         if ( $self->hour || $self->min || $self->sec ) {
             $ical = $self->{dt}->ymd('') . 'T' . $self->{dt}->hms('') . 'Z';
@@ -521,11 +519,11 @@
     my %parm = @parm;
     if (exists $parm{duration}) {
         my $duration = new Date::ICal::Duration ( ical => $parm{duration} );
-        $self->{dt} = $self->{dt}->add_duration( $duration->{dt_duration} );
+        $self->{dt}->add_duration( $duration->{dt_duration} );
         return $self;
     }

-    $self->{dt} = $self->{dt}->add( %parm );
+    $self->{dt}->add( %parm );
     return $self;
 }

Reply via email to