From: Paul Hänsch Date: Thu, 18 Jan 2024 15:32:58 +0000 (+0100) Subject: include title in event storage format, improved year calculation, suppress error... X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=43dc754288741e1b960d7fe267757fa80ed2fa10;p=shellwiki include title in event storage format, improved year calculation, suppress error output --- diff --git a/macros/event b/macros/event index 2d0a14c..2e44100 100755 --- a/macros/event +++ b/macros/event @@ -123,17 +123,14 @@ case $rec_int in rec_int="year";; esac -if [ "$rec_end" ]; then - rec_end="$(date -d "$rec_end" +%s)" -fi +[ "$rec_end" ] && rec_end="$(date -d "$rec_end" +%s)" \ if LOCK './#events'; then sed -i "/^${_DATE} /!d" './#events' - evid="$(wc -l './#events' || printf 0)" - debug "PAGE: $PATH_INFO $evid" - printf '%i %i %i %i %s %i %s\n' \ + evid="$(wc -l <'./#events' || printf 0)" + printf '%i %i %i %i %s %i %s %s\n' \ "$_DATE" "$(date -d "$start_date $start_time" +%s)" "$(date -d "$end_date $end_time" +%s)" \ - "${rec_freq:-0}" "${rec_int:-\\}" "${rec_end:--1}" "$(STRING "${PATH_INFO}#event${evid}")" \ + "${rec_freq:-0}" "${rec_int:-\\}" "${rec_end:--1}" "$(STRING "${title}")" "$(STRING "${PATH_INFO}#event${evid}")" \ >>'./#events' RELEASE './#events' fi @@ -164,12 +161,13 @@ fi while :; do # mod=$(( (_m - m) % rec_freq )); [ $mod -eq 0 ] && mod="$rec_freq"; m=$(( rec_freq - ((_m - m - 1) % rec_freq + 1) + _m )) - y=$((m / 12)) m=$((m % 12)); [ $m -eq 0 ] && y=$((y - 1)) m=12; - nstart="$(printf '%04i-%02i-%02i' "$y" "$m" "$d")" - if isdate "$nstart" && [ $(date -d "$nstart" +%s) -ge $_DATE ]; then + # y=$(((m - 1) / 12)) m=$(((m - 1) % 12 + 1)); # [ $m -eq 0 ] && y=$((y - 1)) m=12; + nstart="$(printf '%04i-%02i-%02i' "$(( (m - 1) / 12 ))" "$(( (m - 1) % 12 + 1 ))" "$d")" + if isdate "$nstart" && [ "$(date -d "$nstart" +%s)" -ge "$_DATE" ]; then break fi >/dev/null - m=$((y * 12 + m)) _m="$((_m + rec_freq))" + # m=$((y * 12 + m)) + _m="$((_m + rec_freq))" done nstart="$(date -d "$nstart $start_time" +%s)" nend="$((end - start + nstart))" @@ -197,7 +195,7 @@ fi ;; esac -if [ "$nstart" -gt "$rec_end" ]; then +if [ "$nstart" -gt "$rec_end" ] 2>/dev/null; then nstart="$start" nend="$end" fi