# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Author: Steven Schubiger <stsc@refcnt.org>
-# Last modified: Sun Jul 21 22:23:31 CEST 2013
+# Last modified: Wed 09 Jun 2021 10:05:08 PM CEST
use strict;
use warnings;
use lib qw(lib);
-my $VERSION = '0.02';
+my $VERSION = '0.06';
my $Config = {
- base_url => 'http://www.lugs.ch/lugs/termine',
+ base_url => 'https://www.lugs.ch/lugs/termine',
input => './termine.txt',
ical_dir => 'ical',
offset => undef,
use Data::ICal ();
use Data::ICal::Entry::Event ();
use Date::ICal ();
-use Encode qw(encode);
+use DateTime ();
use File::Spec ();
-use HTML::Entities qw(decode_entities);
use LUGS::Events::Parser ();
sub new
$location =~ s/\(.+?\)//g;
$more =~ s/<.+?>//g if defined $more;
- sub { decode_entities($_) foreach @_ }->($location, $summary, defined $more ? $more : ());
- sub { $_ = encode('UTF-8', $_) foreach @_ }->($location, $summary, defined $more ? $more : ());
-
- my $offset = $Config->{offset} ? $Config->{offset} : ((localtime)[8] ? '+0200' : '+0100');
-
+ my $get_offset = sub
+ {
+ my ($hour, $minute) = @_;
+ return $Config->{offset} if $Config->{offset};
+ my $dt = DateTime->new(
+ year => $year,
+ month => $month,
+ day => $day,
+ hour => $hour,
+ minute => $minute,
+ time_zone => 'Europe/Zurich',
+ );
+ return $dt->is_dst() ? '+0200' : '+0100';
+ };
$ical_event->add_properties(
dtstamp => Date::ICal->new->ical,
dtstart => Date::ICal->new(
- year => $year,
- month => $month,
- day => $day,
- hour => $time{start_hour},
- min => $time{start_min},
- sec => 00,
- )->ical(offset => $offset),
+ year => $year,
+ month => $month,
+ day => $day,
+ hour => $time{start_hour},
+ min => $time{start_min},
+ sec => 00,
+ offset => $get_offset->(@time{qw(start_hour start_min)}),
+ )->ical,
dtend => Date::ICal->new(
- year => $year,
- month => $month,
- day => $day,
- hour => $time{end_hour},
- min => $time{end_min},
- sec => 00,
- )->ical(offset => $offset),
+ year => $year,
+ month => $month,
+ day => $day,
+ hour => $time{end_hour},
+ min => $time{end_min},
+ sec => 00,
+ offset => $get_offset->(@time{qw(end_hour end_min)}),
+ )->ical,
location => $location,
summary => $summary,
defined $more ? (