Skip Menu |
 

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

Report information
The Basics
Id: 65495
Status: open
Priority: 0/
Queue: Net-Google-Calendar

People
Owner: Nobody in particular
Requestors: hanenkamp [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.0
Fixed in: (no value)



Download (untitled) / with headers
text/plain 199b
It would be nice if there were a way to fetch the reminders from an entry. I have attached a patch to Net::Google::Calendar::Entry which adds a reminders() method for this purpose. Cheers, Sterling
Subject: 0001-Add-a-reminders-method-for-enumerating-existing-remi.patch
From f41a484bfcc43b79fa9bf884c7221e3e60df11fb Mon Sep 17 00:00:00 2001 From: Sterling Hanenkamp <hanenkamp@cpan.org> Date: Sun, 6 Feb 2011 00:13:14 -0600 Subject: [PATCH] Add a reminders() method for enumerating existing reminders --- lib/Net/Google/Calendar/Entry.pm | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-) diff --git a/lib/Net/Google/Calendar/Entry.pm b/lib/Net/Google/Calendar/Entry.pm index 773423a..b2f1003 100644 --- a/lib/Net/Google/Calendar/Entry.pm +++ b/lib/Net/Google/Calendar/Entry.pm @@ -351,7 +351,33 @@ sub reminder { return 1; } +=head2 reminders +Gets the list of reminders attached to this entry. They are returned as a list of arrays references. For example. + + ( [ 'alert', 'days', '2' ], [ 'sms', 'minutes', '15' ] ) + +Each element in the returned list is in the format that may be passed to the C<reminder> method. + +=cut + +sub reminders { + my $self = shift; + + my @reminders; + REMINDER: for my $reminder ($self->_my_getlist($self->{_gd_ns}, 'reminder')) { + for my $type (qw( days hours minutes absoluteTime )) { + my $when = $reminder->getAttribute($type); + if (defined $when) { + push @reminders, + [ $reminder->getAttribute('method'), $type, $when ]; + next REMINDER; + } + } + } + + return @reminders; +} -- 1.7.3.2
Download (untitled) / with headers
text/plain 265b
The suggested patch is incorrect. It only works for recurring events. I didn't initially notice this because most of the events on the calendar I'm using are recurring. The correct solution would look inside the gd:when tags for the reminders for singular events.
Here's a better patch that deals with both recurring and single events better.
Subject: 0001-Add-a-reminders-method-for-enumerating-existing-remi.patch
From d781e18efda4fda2420651941caa3912bf98742c Mon Sep 17 00:00:00 2001 From: Sterling Hanenkamp <hanenkamp@cpan.org> Date: Sun, 6 Feb 2011 00:13:14 -0600 Subject: [PATCH] Add a reminders() method for enumerating existing reminders --- lib/Net/Google/Calendar/Entry.pm | 35 +++++++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-) diff --git a/lib/Net/Google/Calendar/Entry.pm b/lib/Net/Google/Calendar/Entry.pm index 773423a..84339d2 100644 --- a/lib/Net/Google/Calendar/Entry.pm +++ b/lib/Net/Google/Calendar/Entry.pm @@ -351,7 +351,42 @@ sub reminder { return 1; } +=head2 reminders +Gets the list of reminders attached to this entry. They are returned as a list of arrays references. For example. + + ( [ 'alert', 'days', '2' ], [ 'sms', 'minutes', '15' ] ) + +Each element in the returned list is in the format that may be passed to the C<reminder> method. + +=cut + +sub reminders { + my $self = shift; + + my @reminders; + my $gd_when = $self->_my_get($self->{_gd_ns}, 'when'); + if ($gd_when) { + REMINDER: for my $reminder ($gd_when->childNodes) { + my $ns = $self->{_gd_ns}; + $ns = ref($ns) eq 'XML::Atom::Namespace' ? $ns->{uri} : $ns; + + next unless $reminder->namespaceURI eq $ns + and $reminder->localname eq 'reminder'; + + for my $type (qw( days hours minutes absoluteTime )) { + my $when = $reminder->getAttribute($type); + if (defined $when) { + push @reminders, + [ $reminder->getAttribute('method'), $type, $when ]; + next REMINDER; + } + } + } + } + + return @reminders; +} -- 1.7.4


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.