Skip Menu |

This queue is for tickets about the Net-Google-Calendar CPAN distribution.

Report information
The Basics
Id: 36486
Status: resolved
Priority: 0/
Queue: Net-Google-Calendar

People
Owner: Nobody in particular
Requestors: jshirley+cpan [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.94
Fixed in: (no value)



Subject: Namespace and when fix
The namespace gets dropped from critical elements in the <gd:...> namespace, which results in Google simply dropping them. The underlying problem is the SUPER::_initialize call, which isn't populating the $self->{_gd_ns} array. I would have liked to have isolated the cause of that further, but time is not on my side and would rather just alert you to the issue. The other issue is a revamp of the "when" method, which now allows better support for all the other options (single day events without having to unnecessarily add hours on to $end)
Subject: when_ns.patch
=== lib/Net/Google/Calendar/Entry.pm ================================================================== --- lib/Net/Google/Calendar/Entry.pm (revision 8581) +++ lib/Net/Google/Calendar/Entry.pm (local) @@ -54,6 +54,10 @@ $self->SUPER::_initialize(); $self->category({ scheme => 'http://schemas.google.com/g/2005#kind', term => 'http://schemas.google.com/g/2005#event' } ); $self->set_attr('xmlns:gd', 'http://schemas.google.com/g/2005'); + unless ( $self->{_gd_ns} ) { + my $ns = XML::Atom::Namespace->new(gd => 'http://schemas.google.com/g/2005'); + $self->{_gd_ns} = $ns; + } } =head2 id [id] @@ -180,36 +184,61 @@ =head2 when [<start> <end> [allday]] -Get or set the start and end time as supplied as DateTime objects. -End must be more than start. +The when method has multiple behaviors based upon the parameters being passed in -You may optionally pass a paramter in designating if this is an all day event or not. +For full reference, please see L<http://code.google.com/apis/gdata/elements.html#gdWhen> -Returns two DateTime objects depicting the start and end. +The default behavior is to pass in a start and end date, and an optional +allday parameter (true value as the third arguemnt). +If start and end times are the same, with the allday flag, it is a one-day event +Get or set the start and end time as supplied as DateTime objects. +End must be more than start if specified. If end is not specified, it is a +zero-time occurrence. + +Returns up to two DateTime objects depicting the start and end. + =cut sub when { my $self = shift; - if (@_) { + if ( @_ >= 2 ) { my ($start, $end, $allday) = @_; $allday = 0 unless defined $allday; - unless ($end>$start) { - $@ = "End is not less than start"; + my $cmp = DateTime->compare( $start, $end ); + # If they're the same, it must be all day, or $end must be greater than + # start + if ( ( $cmp == 0 and not $allday ) or $cmp > 0 ) { + $@ = "End time must be after start time"; return undef; - } + } $start->set_time_zone('UTC'); $end->set_time_zone('UTC'); my $format = $allday ? "%F" : "%FT%TZ"; + if ( $cmp == 0 ) { + $self->set($self->{_gd_ns}, "when", '', { + startTime => $start->strftime($format), + }); + } else { + $self->set($self->{_gd_ns}, "when", '', { + startTime => $start->strftime($format), + endTime => $end->strftime($format), + }); + } + } + # Single date, is a zero duration event + elsif ( @_ == 1 ) { + my ( $start ) = @_; + $start->set_time_zone('UTC'); $self->set($self->{_gd_ns}, "when", '', { - startTime => $start->strftime($format), - endTime => $end->strftime($format), - }); + startTime => $start->strftime("%FTTZ"), + }); } + my $start = $self->_attribute_get($self->{_gd_ns}, 'when', 'startTime'); my $end = $self->_attribute_get($self->{_gd_ns}, 'when', 'endTime'); my @rets;
CC: undisclosed-recipients: ;
Subject: Re: [rt.cpan.org #36486] Namespace and when fix
Date: Tue, 29 Jul 2008 00:34:33 +0100
To: "J. Shirley via RT" <bug-Net-Google-Calendar [...] rt.cpan.org>
From: Simon Wistow <simon [...] thegestalt.org>
On Thu, Jun 05, 2008 at 02:46:19PM -0400, J. Shirley via RT said: Show quoted text
> The other issue is a revamp of the "when" method, which now allows > better support for all the other options (single day events without > having to unnecessarily add hours on to $end)
Gah, I've been inexcusably crap about applying this. It's now in SVN at http://svn.unixbeard.net/simon/Net-Google-Calendar if you could test it and let me know if it works for you then that would be awesome. Some test cases (either as a .t file or just as some expected behaviours) would be awesome but it's a bit cheeky of me to ask so if you're too busy then it's absolutely fine. Simon