From: Paul Hänsch Date: Mon, 18 Mar 2024 15:33:34 +0000 (+0100) Subject: bugfix: octal interpretation of events at 8am and 9am, suppress calender error when... X-Git-Url: https://git.plutz.net/?p=shellwiki;a=commitdiff_plain;h=fced9f31f3947c647eab57be43fc30c003c98ecb bugfix: octal interpretation of events at 8am and 9am, suppress calender error when event list is empty --- diff --git a/macros/calendar b/macros/calendar index a8f8dd6..b56784c 100755 --- a/macros/calendar +++ b/macros/calendar @@ -43,7 +43,7 @@ while [ $# -gt 0 ]; do case $1 in fi;; esac; done -[ "$*" ] || set -- "*" +[ "$*" ] || set -- "." [ "$depth" -ge 0 -o "$depth" -le 0 ] 2>&- || depth=0 read DY DM DD <<-EOF @@ -68,6 +68,7 @@ rrexpand() { local junk1 start end rrfreq rrint rrend evtitle evlink junk2 while read -r junk1 start end rrfreq rrint rrend evtitle evlink junk2; do + [ ! "$start" ] && continue # empty line [ "$rrend" -eq -1 ] && rrend=9999999999 if [ "$start" -lt "$dend" ] && @@ -274,7 +275,6 @@ cal_month() { dcnt=$((iday - idow * 86400 + ws * 86400)) dow=$ws dcal="$(date -ud @"$dcnt" +%d)" - events="$( printf %s\\n "$events" \ | rrexpand "$dcnt" "$((dcnt + 42 * 86400))" \ diff --git a/macros/event b/macros/event index 4b38810..0ca81af 100755 --- a/macros/event +++ b/macros/event @@ -105,8 +105,13 @@ if [ ! "$end_time" ]; then end_time="23:59" fi +shh=${start_time%:*} shh="${shh#0}" +smm=${start_time#*:} smm="${smm#0}" +ehh=${end_time%:*} ehh="${ehh#0}" +emm=${end_time#*:} emm="${emm#0}" + if [ ! "$end_date" -a "$end_time" -a "$start_time" ]; then - if [ "$((${end_time%:*} * 60 + ${end_time#*:}))" -gt "$((${start_time%:*} * 60 + ${start_time#*:}))" ]; then + if [ "$((ehh * 60 + emm))" -gt "$((shh * 60 + smm))" ]; then end_date="$start_date" else end_date="$(date -ud "@$(($(date -ud "$start_date" +%s) + 86400))" +%F)"