From: Paul Hänsch Date: Thu, 25 Jan 2024 02:24:26 +0000 (+0100) Subject: avoid localising time records X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=f028bf81d0fa37ed84a8e2d167fb54d5480a8177;p=shellwiki avoid localising time records --- diff --git a/macros/event b/macros/event index 2e44100..17aad04 100755 --- a/macros/event +++ b/macros/event @@ -95,7 +95,7 @@ if [ ! "$end_date" -a "$end_time" -a "$start_time" ]; then if [ "$((${end_time%:*} * 60 + ${end_time#*:}))" -gt "$((${start_time%:*} * 60 + ${start_time#*:}))" ]; then end_date="$start_date" else - end_date="$(date -d "@$(($(date -d "$start_date" +%s) + 86400))" +%F)" + end_date="$(date -ud "@$(($(date -ud "$start_date" +%s) + 86400))" +%F)" fi fi @@ -123,20 +123,20 @@ case $rec_int in rec_int="year";; esac -[ "$rec_end" ] && rec_end="$(date -d "$rec_end" +%s)" \ +[ "$rec_end" ] && rec_end="$(date -ud "$rec_end" +%s)" \ if LOCK './#events'; then sed -i "/^${_DATE} /!d" './#events' 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)" \ + "$_DATE" "$(date -ud "$start_date $start_time" +%s)" "$(date -ud "$end_date $end_time" +%s)" \ "${rec_freq:-0}" "${rec_int:-\\}" "${rec_end:--1}" "$(STRING "${title}")" "$(STRING "${PATH_INFO}#event${evid}")" \ >>'./#events' RELEASE './#events' fi -start="$(date -d "$start_date $start_time" +%s)" - end="$(date -d "$end_date $end_time" +%s)" +start="$(date -ud "$start_date $start_time" +%s)" + end="$(date -ud "$end_date $end_time" +%s)" if [ $_DATE -le $end ]; then nstart="$start" nend="$end" @@ -153,8 +153,8 @@ fi ;; month) { read _y _m _d; read y m d; } <<-EOF - $(date -d @$_DATE +"%Y %_m %_d" - date -d @$start +"%Y %_m %_d" + $(date -ud @$_DATE +"%Y %_m %_d" + date -ud @$start +"%Y %_m %_d" ) EOF _m=$((_y * 12 + _m)) m=$((y * 12 + m)) @@ -163,31 +163,31 @@ fi m=$(( rec_freq - ((_m - m - 1) % rec_freq + 1) + _m )) # 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 + if isdate "$nstart" && [ "$(date -ud "$nstart" +%s)" -ge "$_DATE" ]; then break fi >/dev/null # m=$((y * 12 + m)) _m="$((_m + rec_freq))" done - nstart="$(date -d "$nstart $start_time" +%s)" + nstart="$(date -ud "$nstart $start_time" +%s)" nend="$((end - start + nstart))" ;; year) { read _y _m _d; read y m d; } <<-EOF - $(date -d @$_DATE +"%Y %_m %_d" - date -d @$start +"%Y %_m %_d" + $(date -ud @$_DATE +"%Y %_m %_d" + date -ud @$start +"%Y %_m %_d" ) EOF while :; do # mod=$(( ( _y - y ) % rec_freq )); [ $mod -eq 0 ] && mod="$rec_freq" y=$(( rec_freq - ((_y - y - 1) % rec_freq + 1) + _y )) nstart="$(printf '%04i-%02i-%02i' "$y" "$m" "$d")" - if isdate "$nstart" && [ $(date -d "$nstart" +%s) -ge $_DATE ]; then + if isdate "$nstart" && [ $(date -ud "$nstart" +%s) -ge $_DATE ]; then break fi >/dev/null _y="$((_y + rec_freq))" done - nstart="$(date -d "$nstart $start_time" +%s)" + nstart="$(date -ud "$nstart $start_time" +%s)" nend="$((end - start + nstart))" ;; '') @@ -203,9 +203,9 @@ fi [div .macro .event #event${evid} [label . $(HTML "$title")] [dl - [dt $(_ Start:)][dd $(date -d @$nstart +"%F %T")] - [dt $(_ End:)][dd $(date -d @$nend +"%F %T")] - [dt $(_ Until:)][dd $(date -d @$rec_end +"%F %T")] + [dt $(_ Start:)][dd $(date -ud @$nstart +"%F %T")] + [dt $(_ End:)][dd $(date -ud @$nend +"%F %T")] + [dt $(_ Until:)][dd $(date -ud @$rec_end +"%F %T")] ] ] EOF @@ -219,10 +219,10 @@ EOF # PRODID:ShellWiki Event Macro # BEGIN:VEVENT # UID:$uid@$(HEADER Host) -# DTSTAMP:TZID=${tzid}:$(date +%Y%m%dT%H%M%S) -# DTSTART:TZID=${tzid}:$(date +%Y%m%dT%H%M%S -d "$start_date $start_time") +# DTSTAMP:TZID=${tzid}:$(date -u +%Y%m%dT%H%M%S) +# DTSTART:TZID=${tzid}:$(date -u +%Y%m%dT%H%M%S -d "$start_date $start_time") # DURATION: -# RRULE:FREQ=$ec_freq;INTERVAL=$rec_int;UNTIL=$(date +%Y%m%dT000000Z -d "$rec_end") +# RRULE:FREQ=$ec_freq;INTERVAL=$rec_int;UNTIL=$(date -u +%Y%m%dT000000Z -d "$rec_end") # SUMMARY: # COMMENT: # END:VEVENT