Re: DateTime::Format::ICal

[email protected] (Dave Rolsky)
Newsgroups perl.datetime
Message-ID <[email protected]>
On Tue, 4 Mar 2008, Bill Moseley wrote:

> I'm not very familiar with icalendar format.
>
> http://search.cpan.org/src/DROLSKY/DateTime-Format-ICal-0.08/lib/DateTime/Format/ICal.pm
>
> format_datetime() only adds the time if it's not 00:00:00:
>
>    my $base =
>        ( $dt->hour || $dt->min || $dt->sec ?
>          sprintf( '%04d%02d%02dT%02d%02d%02d',
>                   $dt->year, $dt->month, $dt->day,
>                   $dt->hour, $dt->minute, $dt->second ) :
>          sprintf( '%04d%02d%02d', $dt->year, $dt->month, $dt->day )
>        );
>
>    return $base if $tz->is_floating;
>
>    return $base . 'Z' if $tz->is_utc;
>
>    return 'TZID=' . $tz->name . ':' . $base;

I'm honestly not entirely sure why I bothered doing that (I think I mostly 
copied this code from Date::ICal), but I think it's ok.

> I glanced over RFC 2445 and I don't see this as a problem.  But

Yes, RFC 2445 makes it clear that DTEND (and DTSTART) can be a DATE, 
rather than a full DATE-TIME, but ...

> this "validator" at http://severinghaus.org/projects/icv/ reports:
>
> Error: Error was: Error at line 181: Unparseable date: "20070424Z"
> Cause: Caused by: Unparseable date: "20070424Z"
>
> With the problem entry being:
>
>    DTEND:20070424Z
>
> Is this a problem with the validator?

I'm not sure. Looking more closely at RFC2445, it seems that a DATE value 
should not include a time zone.

I think the best thing to do is to simply always produce a DATE-TIME 
value. It's not like the fact that the time is midnight somehow means that 
the user wants less precision.


-dave

/*===================================================
VegGuide.Org                        www.BookIRead.com
Your guide to all that's veg.       My book blog
===================================================*/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.