From 181148e9f80081e3991c6e8b0c8b54a37a01495a Mon Sep 17 00:00:00 2001 From: ipitio <21136719+ipitio@users.noreply.github.com> Date: Fri, 26 Jan 2024 05:46:49 -0500 Subject: [PATCH] round up --- advanced/Scripts/webpage.sh | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index 7947b1930b..0a7b6c6a70 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -634,28 +634,27 @@ generate_systemd_calendar() { local total_seconds=$(echo "$interval_hours * 3600" | bc) local freq_entries=() - if (( $(echo "$total_seconds < 60" | bc -l) )); then # seconds + if (( $(echo "$total_seconds < 60" | bc -l) )); then # less than a minute + total_seconds=60 + fi + if (( $(echo "$total_seconds >= 60 && $total_seconds < 3600" | bc -l) )); then # less than an hour + local minute_interval=$(echo "$total_seconds / 60" | bc) + freq_entries+=("*-*-* *:00/$minute_interval:00") + elif (( $(echo "$total_seconds == 3600" | bc -l) )); then # an hour + freq_entries+=("*-*-* *:00:00") + elif (( $(echo "86400 % $total_seconds == 0" | bc -l) )); then # factors of a day + local hour_interval=$(echo "$total_seconds / 3600" | bc) + freq_entries+=("*-*-* 00/$hour_interval:00:00") + elif (( $(echo "$total_seconds < 86400" | bc -l) )); then # less than a day local current_second=0 while (( $(echo "$current_second < 86400" | bc -l) )); do local hour=$(echo "$current_second / 3600" | bc) local minute=$(echo "($current_second % 3600) / 60" | bc) - local second=$(echo "$current_second % 60" | bc) - hour=${hour%.*} minute=${minute%.*} - second=${second%.*} - - freq_entries+=("*-*-* $(printf "%02d:%02d:%02d" $hour $minute $second)") + freq_entries+=("*-*-* $(printf "%02d:%02d:00" $hour $minute)") current_second=$(echo "$current_second + $total_seconds" | bc) done - elif (( $(echo "$total_seconds >= 60 && $total_seconds < 3600" | bc -l) )); then # minutes - local minute_interval=$(echo "$total_seconds / 60" | bc) - freq_entries+=("*-*-* *:00/$minute_interval:00") - elif (( $(echo "$total_seconds == 3600" | bc -l) )); then # an hour - freq_entries+=("*-*-* *:00:00") - elif (( $(echo "86400 % $total_seconds == 0" | bc -l) )); then # factors of a day - local hour_interval=$(echo "$total_seconds / 3600" | bc) - freq_entries+=("*-*-* 00/$hour_interval:00:00") else # days local full_days=$(echo "$interval_hours / 24" | bc) local remaining_hours=$(echo "$interval_hours - ($full_days * 24)" | bc)