summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/events2md.pl36
1 files changed, 21 insertions, 15 deletions
diff --git a/bin/events2md.pl b/bin/events2md.pl
index 847b7b9..c694d9a 100755
--- a/bin/events2md.pl
+++ b/bin/events2md.pl
@@ -10,7 +10,7 @@ use POSIX qw(locale_h);
use locale;
use Encode qw(decode_utf8); # TODO: modernize CalDAV access instead
use Net::Netrc;
-use List::Util qw(pairs);
+use List::Util qw(first);
use IO::Interactive::Tiny;
use Log::Any qw($log);
@@ -21,8 +21,6 @@ use IO::Prompter;
use Cal::DAV;
use Data::ICal;
use iCal::Parser;
-use List::Util qw(first);
-use List::MoreUtils qw(nsort_by qsort);
use DateTime;
use Try::Tiny;
use Path::Tiny;
@@ -156,23 +154,31 @@ if ($OUTPUT_FILE) {
$output_path->parent->mkpath;
$output_path->remove;
}
-for my $year ( map { $_->value }
- nsort_by { $_->key } pairs %{ $events->{events} } )
+for my $year (
+ map { $events->{events}{$_} }
+ sort { $a <=> $b } keys %{ $events->{events} }
+ )
{
- for my $month ( map { $_->value } nsort_by { $_->key } pairs %$year ) {
- for my $day ( map { $_->value } nsort_by { $_->key } pairs %$month ) {
- my @events = map {
+ for my $month (
+ map { $year->{$_} }
+ sort { $a <=> $b } keys %$year
+ )
+ {
+ for my $day (
+ map { $month->{$_} }
+ sort { $a <=> $b } keys %$month
+ )
+ {
+ my @events = sort {
+ 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' )
+ } 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, );
}