Menu

#64 N::I::Duration (?) parse failure

major
open
nobody
Net-ICal (57)
5
2012-05-22
2001-09-19
Tim Mooney
No

I'm calling

my $calref =
Net::ICal::Calendar->new_from_ical($istring);

The string is a valid ICal stream, and
contains an event with a duration line like this:

DURATION:P0DT1H0M0S

I'm iterating through the events in the calendar in
my code, and I can see that most of the duration is
not parsed correctly -- when my code executes:

    if (defined($vevent->duration)) {
        print "Duration: ",

$vevent->duration->as_ical_value(), "\n";
}

I just get

Duration: PT0S

By inserting debugging prints in various modules, I've
been able to determine that Component's _load_property
method is returning the result of calling:

Net::ICal::Duration->new_from_ical(DURATION:P0DT1H0M0S)

If I comment out the `return
$class->new_from_ical($line)
in Component.pm's _load_property and then call it and
dump out the various peices of the resulting Duration,
like
this:

my $dref = $class->new_from_ical($line);
print "weeks:", $dref->weeks, "\n";
print "days :", $dref->days, "\n";
print "hours:", $dref->hours, "\n";
print "mins :", $dref->minutes, "\n";
print "secs :", $dref->seconds, "\n";
print "is_valid returns ", $dref->is_valid(), "\n";
print "as_ical returns ", $dref->as_ical(), "\n";
print "as_ical_value returns ", $dref->as_ical_value(),
"\n";

I get:

Use of uninitialized value in addition (+) at
/local/lib/site_perl/5.6.1/Net/ICal/Duration.pm line
651, <STDIN> line 51.
weeks:Net::ICal::Duration=HASH(0x140bb25a8)
Use of uninitialized value in print at
/local/lib/site_perl/5.6.1/Net/ICal/Component.pm line
700, <STDIN> line 51.
days :
Use of uninitialized value in print at
/local/lib/site_perl/5.6.1/Net/ICal/Component.pm line
701, <STDIN> line 51.
hours:
Use of uninitialized value in print at
/local/lib/site_perl/5.6.1/Net/ICal/Component.pm line
702, <STDIN> line 51.
mins :
Use of uninitialized value in print at
/local/lib/site_perl/5.6.1/Net/ICal/Component.pm line
703, <STDIN> line 51.
secs :
is_valid returns 1
as_ical returns :P5380973992W
as_ical_value returns P5380973992W

This means that days, hours, minutes, and seconds are
undefined,
weeks is defined but is a hash (rather than a value) or
hashref.

I don't understand Class::MethodMapper enough to know
where
the actual failure is, though. Since Duration doesn't
have a
new_from_ical method, the method must be coming in from
inheritance from Property. I don't see where the
actual duration
parsing is happening in this case -- it's not in
Duration's
_set_from_ical, which I can see is not being called.

Any suggestions for where the failure might be?

Discussion


Log in to post a comment.

MongoDB Logo MongoDB