Question

There is a huge Perl module Data::ICal that makes it possible to create iCal files that can be added to Calendar app on mac (they also can be added to a lot of other programmes).

I've used Data::ICal and I have written a simple script that creates iCal file. I've added it the Calendar app and it works fine.

Here is the listing:

#!/usr/bin/perl

use strict;
use warnings FATAL => 'all';

use Data::ICal;
use Data::ICal::Entry::Event;
use Date::ICal;
use File::Slurp;

my $calendar = Data::ICal->new();

my $ical_date = Date::ICal->new(
    year => 2013,
    month => 9,
    day => 6,
);

my $event = Data::ICal::Entry::Event->new();
$event->add_properties(
    summary => "my party",
    description => "I'll cry if I want to",
    dtstart => $ical_date->ical(),
);

$calendar->add_entry($event);

write_file('sample.ics', $calendar->as_string);

But now I want to mark this event as lasting for the whole day. I've grepped throw the module source docs and code, but I havn't found the way to do it.

How can I mark this event as lasting for the whole day?

Was it helpful?

Solution

According to this description on innerjoin, all you have to do is set dtstart and dtend as YYYYMMDD (no hours or below) where start is the day (of your party) and end the next day.

At least with thunderbird/sunbird this works flawlessly:

#!/usr/bin/perl

use strict;

use Data::ICal;
use Data::ICal::Entry::Event;
use File::Slurp;

my $calendar = Data::ICal->new();

my $event = Data::ICal::Entry::Event->new();
$event->add_properties(
    summary     => "my party",
    description => "I'll cry if I want to",
    dtstart     => "20130906",
    dtend       => "20130907",
);

$calendar->add_entry($event);

write_file('sample.ics', $calendar->as_string);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top