-
-
Save leonid-shevtsov/10267e2f210e3d8018055eb48cc65d1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn build-schedule [] | |
(let [start-date (t/zoned-date-time "2022-11-01T00:00:00+02:00[Europe/Kiev]") | |
days (range 1 30) | |
interval (t/new-duration 6 :hours) | |
duration (t/new-duration 2 :hours) | |
for-day (fn [day] | |
(let [day-offset (* 2 (nth [0 2 1] (mod day 3))) | |
offset-duration (t/+ (t/new-duration (- day 1) :days) | |
(t/new-duration day-offset :hours)) | |
first-blackout (t/>> start-date offset-duration)] | |
(take 4 (iterate #(t/>> % interval) first-blackout)))) | |
dates (mapcat for-day days)] | |
(map-indexed | |
(fn [index date] | |
{ | |
:from (-> date t/instant i/to-epoch-milli) | |
:to (-> (t/>> date duration) t/instant i/to-epoch-milli) | |
:description "Відключення" | |
:uid (str "me.shevtsov.leonid.blackout-schedule.Nov." index)}) | |
dates))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN:VCALENDAR | |
PRODID:-//Leonid Shevtsov//Blackout-Schedule 0.0.1//EN | |
VERSION:2.0 | |
CALSCALE:GREGORIAN | |
BEGIN:VEVENT | |
DTSTAMP:20221104T222050Z | |
DTSTART:20221101T040000 | |
DTEND:20221101T060000 | |
SUMMARY:Відключення | |
UID:me.shevtsov.leonid.blackout-schedule.Nov.0 | |
END:VEVENT | |
END:VCALENDAR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment