[Украина][Киев][Bash] График отключений напруги

А если лень ходить на сайт ДТЕК, как мне...

4 часа нет напруги. 2 часа есть точно. 3 часа - не ясно. Период - 9 часов.

#!/usr/bin/env bash

# adjust this:
blackout_start=$(date -d '2022-12-15 15:00:00 EET' +%s)

# 24h. https://unix.stackexchange.com/questions/553679/set-clock-to-24-hour-format-for-all-users
LC_TIME=en_GB.UTF-8

# 4 hours - blackout
# 2 hours - power
# 3 hours - maybe blackout

SECONDS_IN_HOUR=3600

for i in {1..6}
do

power_on=$(echo $blackout_start+4*$SECONDS_IN_HOUR | bc)
maybe=$(echo $power_on+2*$SECONDS_IN_HOUR | bc)

echo -ne "blackout: "
date -d @$blackout_start
echo -ne "power on: "
date -d @$power_on
echo -ne "maybe:    "
date -d @$maybe

blackout_start=$(echo $maybe+3*$SECONDS_IN_HOUR | bc)

done
blackout: Thu 15 Dec 15:00:00 EET 2022
power on: Thu 15 Dec 19:00:00 EET 2022
maybe:    Thu 15 Dec 21:00:00 EET 2022
blackout: Fri 16 Dec 00:00:00 EET 2022
power on: Fri 16 Dec 04:00:00 EET 2022
maybe:    Fri 16 Dec 06:00:00 EET 2022
blackout: Fri 16 Dec 09:00:00 EET 2022
power on: Fri 16 Dec 13:00:00 EET 2022
maybe:    Fri 16 Dec 15:00:00 EET 2022
blackout: Fri 16 Dec 18:00:00 EET 2022
power on: Fri 16 Dec 22:00:00 EET 2022
maybe:    Sat 17 Dec 00:00:00 EET 2022
blackout: Sat 17 Dec 03:00:00 EET 2022
power on: Sat 17 Dec 07:00:00 EET 2022
maybe:    Sat 17 Dec 09:00:00 EET 2022
blackout: Sat 17 Dec 12:00:00 EET 2022
power on: Sat 17 Dec 16:00:00 EET 2022
maybe:    Sat 17 Dec 18:00:00 EET 2022

Ну не красота? Хардкорные юниксоиды могут сделать себе напоминания в шелле...

Еще один мой пост на тему напруги в Киеве.

(the post first published at 20221215.)


List of my other blog posts.

Yes, I know about these lousy Disqus ads. Please use adblocker. I would consider to subscribe to 'pro' version of Disqus if the signal/noise ratio in comments would be good enough.