X-Git-Url: http://pere.pagekite.me/gitweb/homepage.git/blobdiff_plain/6d1b7d4e15f9fa64d0c1ac875f13ac3679ca9d3a..b8bed0863f73e2f11f7daaa2ab539df11f5cfa95:/linux/plan2icalendar
diff --git a/linux/plan2icalendar b/linux/plan2icalendar
index 4571fc1ab5..02fc237b36 100755
--- a/linux/plan2icalendar
+++ b/linux/plan2icalendar
@@ -7,6 +7,8 @@
#
# plan,
# icalendar, RFC 2445, iCalendar>
+#
+# Depend on debian package libdate-ical-perl
use warnings;
use strict;
@@ -18,12 +20,12 @@ use Date::ICal;
my @events;
my %opts;
-my $debug = 0;
-unless (getopts('if:o:', \%opts)) {
+unless (getopts('dif:o:', \%opts)) {
usage();
exit 1;
}
+my $debug = $opts{d} || 0;
my $input = $opts{f};
my $output = $opts{o};
@@ -45,6 +47,7 @@ Imports or exports between plan and iCalendar.
-i import ical file
-f infile read input from 'infile'
-o outfile read output from 'outfile'
+ -d enable debug output
EOF
}
sub read_planfile {
@@ -151,25 +154,27 @@ sub read_icalendar {
open (ICALENDAR, "<$filename") or die "Unable to read from $filename";
my $oldval = $/;
$/ = "\r\n";
+ print STDERR "Loading $filename\n" if $debug;
while () {
- chomp;
- if (m/^BEGIN:VEVENT/) {
- my %event;
- while () {
- chomp;
- last if (m/END:VEVENT/);
- $event{description} = $1 if (m/^DESCRIPTION\s*:\s*(.+)$/);
- $event{created} = $1 if (m/^CREATED\s*:\s*(.+)$/);
- $event{dtend} = $1 if (m/^DTEND\s*:\s*(.+)$/);
- $event{dtstamp} = $1 if (m/^DTSTAMP\s*:\s*(.+)$/);
- $event{dtstart} = $1 if (m/^DTSTART\s*:\s*(.+)$/);
- $event{last-modified} = $1 if (m/^LAST-MODIFIED\s*:\s*(.+)$/);
- $event{sequence} = $1 if (m/^SEQUENCE\s*:\s*(.+)$/);
- $event{summary} = $1 if (m/^SUMMARY\s*:\s*(.+)$/);
- $event{uid} = $1 if (m/^UID\s*:\s*(.+)$/);
- }
- push @events, \%event;
- }
+ chomp;
+ if (m/^BEGIN:VEVENT/) {
+ my %event;
+ while () {
+ chomp;
+ last if (m/END:VEVENT/);
+ $event{description} = $1 if (m/^DESCRIPTION\s*:\s*(.+)$/);
+ $event{created} = $1 if (m/^CREATED\s*:\s*(.+)$/);
+ $event{dtend} = $1 if (m/^DTEND\s*:\s*(.+)$/);
+ $event{dtstamp} = $1 if (m/^DTSTAMP\s*:\s*(.+)$/);
+ $event{dtstart} = $1 if (m/^DTSTART\s*:\s*(.+)$/);
+ $event{last-modified} = $1 if (m/^LAST-MODIFIED\s*:\s*(.+)$/);
+ $event{sequence} = $1 if (m/^SEQUENCE\s*:\s*(.+)$/);
+ $event{summary} = $1 if (m/^SUMMARY\s*:\s*(.+)$/);
+ $event{uid} = $1 if (m/^UID\s*:\s*(.+)$/);
+ }
+ push @events, \%event;
+ print STDERR "Event pushed\n" if $debug;
+ }
}
close (ICALENDAR);
$/ = $oldval;
@@ -181,6 +186,9 @@ sub utf8tolocalmap {
$string =~ s/ø/ø/g;
$string =~ s/æ/æ/g;
$string =~ s/Ã¥/å/g;
+ $string =~ s/Ã
/Å/g;
+ $string =~ s/«/«/g;
+ $string =~ s/»/»/g;
return $string;
}