X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=macros%2Fevent;h=0ca81afba7e6ac2e79e0d26b34b602bcd25793be;hb=442c9d9bf6e9db8e2daa6604a7d20b412e0503fb;hp=1f77cfb46bff13492b2a586929388b06bbe9b90f;hpb=3601593ab76ccf5ea1360c6c588bd3326e5b956d;p=shellwiki diff --git a/macros/event b/macros/event index 1f77cfb..0ca81af 100755 --- a/macros/event +++ b/macros/event @@ -1,5 +1,19 @@ #!/bin/sh +# Copyright 2023 - 2024 Paul Hänsch +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +# IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + . $_EXEC/cgilite/cgilite.sh . $_EXEC/cgilite/storage.sh . $_EXEC/datetime.sh @@ -91,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)"