summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/events2md.pl31
1 files changed, 15 insertions, 16 deletions
diff --git a/bin/events2md.pl b/bin/events2md.pl
index 84880af..847b7b9 100755
--- a/bin/events2md.pl
+++ b/bin/events2md.pl
@@ -22,7 +22,7 @@ use Cal::DAV;
use Data::ICal;
use iCal::Parser;
use List::Util qw(first);
-use List::MoreUtils qw(nsort_by sort_by);
+use List::MoreUtils qw(nsort_by qsort);
use DateTime;
use Try::Tiny;
use Path::Tiny;
@@ -161,21 +161,20 @@ for my $year ( map { $_->value }
{
for my $month ( map { $_->value } nsort_by { $_->key } pairs %$year ) {
for my $day ( map { $_->value } nsort_by { $_->key } pairs %$month ) {
- for (
- sort_by {
- $_->value->{DTSTART}
- . $_->value->{DTEND}
- . ( $_->value->{SUMMARY} || '' )
- }
- pairs %$day
- )
- {
- print_event(
- $calendar_entries{VEVENT}{ $_->key },
- $_->value->{DTSTART},
- $_->value->{DTEND},
- $output_path,
- );
+ my @events = map {
+ [ $calendar_entries{VEVENT}{$_},
+ $day->{$_}{DTSTART}, $day->{$_}{DTEND}
+ ]
+ } keys %$day;
+ qsort {
+ DateTime->compare( $a->[1], $b->[1] )
+ || DateTime->compare( $a->[2], $b->[2] )
+ || get_property_string( $a->[0], 'summary' )
+ cmp get_property_string( $b->[0], 'summary' )
+ }
+ @events;
+ for (@events) {
+ print_event( $_->[0], $_->[1], $_->[2], $output_path, );
}
}
}