Skip Menu |
 

This queue is for tickets about the Date-ICal CPAN distribution.

Report information
The Basics
Id: 81391
Status: open
Priority: 0/
Queue: Date-ICal

People
Owner: Nobody in particular
Requestors: asjo [...] koldfront.dk
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)

Attachments


Subject: Can't output time 00:00
Download (untitled) / with headers
text/plain 380b
I am using Data::ICal to export a calendar to an .ics file and importing it on an Android phone using iCalSync. iCalSync doesn't like dates without a time - probably a bug in iCalSync, but I need to work around it. Date::ICal skips the time if hours, minutes and seconds aren't true - maybe it should only skip it they aren't defined? Patch attached. Best regards, Adam
Subject: output_time_if_defined.patch
--- ICal.pm_orig 2012-11-23 22:58:19.361238426 +0100 +++ ICal.pm 2012-11-23 22:58:39.076759868 +0100 @@ -284,7 +284,7 @@ # make output in UTC by default # if we were originally given this time in offset # form, we'll need to adjust it for output - if ( $self->hour || $self->min || $self->sec ) { + if ( defined $self->hour || defined $self->min || defined $self->sec ) { $ical = sprintf( '%04d%02d%02dT%02d%02d%02dZ', $self->year, $self->month, $self->day, $self->hour, $self->minute, $self->second );
Download (untitled) / with headers
text/plain 614b
The below was filed in the Data::ICal queue originally, but it's a feature request for Date::ICal. It's an easy mistake being off by one letter. :) On Fri Nov 23 17:47:18 2012, asjo@koldfront.dk wrote: Show quoted text
> I am using Data::ICal to export a calendar to an .ics file and importing > it on an Android phone using iCalSync. > > iCalSync doesn't like dates without a time - probably a bug in iCalSync, > but I need to work around it. > > Date::ICal skips the time if hours, minutes and seconds aren't true - > maybe it should only skip it they aren't defined? > > Patch attached. > > Best regards, > > Adam
Subject: Re: [rt.cpan.org #81391] Can't output time 00:00
Date: Tue, 04 Dec 2012 19:24:00 +0100
To: bug-Date-ICal [...] rt.cpan.org
From: asjo [...] koldfront.dk (Adam Sjøgren)
Download (untitled) / with headers
text/plain 582b
On Mon, 3 Dec 2012 17:39:56 -0500, Thomas Sibley wrote: Show quoted text
> The below was filed in the Data::ICal queue originally, but it's a > feature request for Date::ICal. It's an easy mistake being off by one > letter. :)
Thanks for the correction - I think I simply assumed that Date::ICal was part of Data::ICal (I use them together, maybe by typo, even; it's an oldish program)! Sorry for the mix-up :-) Best regards, Adam -- "Money always takes the place of life" Adam Sjøgren asjo@koldfront.dk
Download (untitled) / with headers
text/plain 1.3k
I also ran into this issue, but defined a method guaranteed to return a DATE-TIME, leaving the existing behavior alone. (I don't know why anyone would rely on the existing behavior, but as it's been a long time, who knows?) In any case, the nice thing about this approach is that until/unless the maintainer comes up with a fix, the code can go in your application. If it ever IS fixed, this code is harmless. And, the maintainer could just add the subroutine... # Version of 'ical' method that ensures # that returned string is a DATE-TIME, not just a DATE (at 00:00:00Z) # Extends Date::ICal objects. Same arguments as 'ical'. # Or, you can call it with the result of Date::ICal::ical # to fixup the string. # # $x = Date::ICal->new( … ) # $string = $x->ical_dt( offset => '+0400' ); # $ical = $x->ical; $string = Date::ICal::ical_dt( $ical, offset => … ) # Except for the object or string, arguments are optional. # The optional arguments are ignored if a string is supplied. # # See https://rt.cpan.org/Public/Bug/Display.html?id=81391 { package Date::ICal; sub ical_dt { my $dt = shift; $dt = $dt->ical( @_ ) if( ref $dt ); # If just a UTC date, it's midnight UTC. # Convert the DATE to a DATE-TIME. $dt = "$1T000000Z" if( $dt =~ /^(\d{8})Z$/ ); return $dt; } }


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.