Wayne Arthurton Wayne Arthurton - 10 months ago 35
Perl Question

How do I use Date::Manip to create a date usable by Date::ICal?

I need to take the result of a

Date::Manip ParseDateString()
and use it as the bast for an

has the following date creating inputs:

use Date::ICal;

$ical = Date::ICal->new( ical => '19971024T120000' );
$ical = Date::ICal->new( epoch => time );
$ical = Date::ICal->new( year => 1964,
month => 10, day => 16, hour => 16,
min => 12, sec => 47 );

Date::Manip ParseDateString()
returns a standard date value.

How should I use that date in the ICal date? Convert to epoch? Can it easily be converted to the ical format? I feel like this should be easier than it is.


I did some further CPAN hunting and came up with the module DateTime::Format::DateManip

Using this I was able to convert it to a DateTime representation and then get the epoch from that using the epoch method available in DateTime:

my $cagedate = ParseDateString($cagewatch);
my $cagedatetime = DateTime::Format::DateManip->parse_datetime($cagedate);

    summary => $cagemovie,
    description => $cagemovie,
    dtstart   => Date::ICal->new( epoch => $cagedatetime->epoch )->ical,

Just in case you are curious about the CAGE variables. I was parsing the list of movies for the Year of the Cage. All Nick Cage, all year. Oh yeah.