From 07d4c01652c3b3f72205e552e8dd8d543942e72b Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sun, 13 Aug 2023 11:34:07 +0200 Subject: handle event without end time --- bin/events2md.pl | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/events2md.pl b/bin/events2md.pl index c758577..9c10ce0 100755 --- a/bin/events2md.pl +++ b/bin/events2md.pl @@ -171,9 +171,14 @@ sub print_event } } my $location = get_property_string( $entry, 'location' ); - my $time_begin = ucfirst( $start->strftime('%A') ); - $time_begin .= $start->strftime(' %e. %B kl. %k.%M'); - my $time_end = $end->strftime('%k.%M'); + my $date_begin = $start->strftime('%A %e. %B'); + my $time_begin = $start->strftime('%k.%M'); + my $time_end = $end->strftime('%k.%M'); + my $time_brief = ucfirst("$date_begin kl. $time_begin"); + my $timespan + = $time_end + ? ucfirst("$date_begin kl. $time_begin-$time_end") + : undef; my %attachments; if ( $entry->property('attach') ) { for ( @{ $entry->property('attach') } ) { @@ -185,7 +190,7 @@ sub print_event } } - $_ = "### $time_begin."; + $_ = "### $time_brief."; $_ .= " $summary" if $summary; $_ .= "\n$description"; @@ -193,8 +198,8 @@ sub print_event if @attendees; $_ .= " \n**Mødested:** $location" if $location; - $_ .= " \n**Tid:** ${time_begin}-${time_end}." - if $time_begin and $time_end; + $_ .= " \n**Tid:** $timespan." + if $timespan; $_ .= " \n**Pris:** $price" if $price; $_ .= " \n[Køb billet på Billetto]($attachments{'billetto.dk'}[0])" -- cgit v1.2.3