2 # SCRIPTNAME DOES_SOMETHING
3 # and is released under the terms of the GNU GPL version 3, or any
4 # later version, at your option. See the file README and COPYING for
6 # Copyright 2016 by Don Armstrong <don@donarmstrong.com>.
17 use POSIX qw(strftime);
19 use DateTime::Format::DateParse qw(parse_datetime);
23 SCRIPTNAME - DOES_SOMETHING
30 --debug, -d debugging level (Default 0)
31 --help, -h display this help
32 --man, -m display manual
40 Debug verbosity. (Default 0)
44 Display brief usage information.
61 my %options = (debug => 0,
67 'debug|d+','help|h|?','man|m');
69 pod2usage() if $options{help};
70 pod2usage({verbose=>2}) if $options{man};
72 $DEBUG = $options{debug};
76 # push @USAGE_ERRORS,"You must pass something";
79 pod2usage(join("\n",@USAGE_ERRORS)) if @USAGE_ERRORS;
82 my $xml = XML::LibXML->load_xml(string => get('https://debconf16.debconf.org/schedule/pentabarf.xml'));
87 X-WR-CALNAME:pentabarf_to_ics
88 PRODID:-//PentabarfToICS//EN
90 X-WR-CALDESC:Pentabarf To ICS
93 my $timestamp = strftime('%Y%m%dT%H%M%SZ',gmtime);
94 for my $event ($xml->findnodes('.//event')) {
95 print STDERR $event->toString if $DEBUG;
96 my $id = $event->getAttribute('id');
97 my $start = DateTime::Format::DateParse->parse_datetime(node_content($event,'date'));
98 $start->set_time_zone('UTC');
99 my $start_stamp = strftime('%Y%m%dT%H%M%SZ',gmtime($start->epoch));
100 my $duration = node_content($event,'duration');
101 if (not defined $duration or $duration eq ':') {
102 $duration = node_content($xml,'timeslot_duration');
104 my ($h,$m) = $duration =~ /(\d+)\:(\d+)/;
105 $duration = DateTime::Duration->new(hours => $h,minutes => $m);
106 my $stop_stamp = strftime('%Y%m%dT%H%M%SZ',gmtime(($start+$duration)->epoch));
107 my $summary = node_content($event,'title');
108 my $description = node_content($event,'description');
109 $description =~ s/\n/\\n/g;
110 my $url = node_content($event,'full_conf_url');
111 my $type = node_content($event,'type');
116 DTSTART: $start_stamp
119 DESCRIPTION:: $description
133 my ($xml,$node) = @_;
135 my ($n) = $xml->findnodes(".//$node");
136 return $n->textContent();