diff options
author | Jonas Smedegaard <dr@jones.dk> | 2021-06-29 14:12:14 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2024-08-27 23:39:36 +0200 |
commit | d027c90c821e09fac40628fe81977c5b56af95df (patch) | |
tree | 4aa6d396d29d56a5aa5529187a0e69a010f94652 | |
parent | 687b7dfed82d0c7aa9aaaee72265e451f2f39240 (diff) |
stop use List::MoreUtils
-rwxr-xr-x | bin/events2md.pl | 36 |
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, ); } |