Created
December 2, 2022 12:17
-
-
Save jogspokoen/d0723ce92ad47c479bbcaa7f032bd66b to your computer and use it in GitHub Desktop.
afval calendar generator
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
import json | |
import datetime | |
from uuid import uuid4 | |
j = json.load(open("afval_2021.json")) | |
print("""BEGIN:VCALENDAR | |
VERSION:2.0 | |
PRODID:-//Maka//Maka | |
BEGIN:VTIMEZONE | |
TZID:Europe/Berlin | |
TZURL:http://tzurl.org/zoneinfo-outlook/Europe/Berlin | |
X-LIC-LOCATION:Europe/Berlin | |
BEGIN:DAYLIGHT | |
TZOFFSETFROM:+0100 | |
TZOFFSETTO:+0200 | |
TZNAME:CEST | |
DTSTART:19700329T020000 | |
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU | |
END:DAYLIGHT | |
BEGIN:STANDARD | |
TZOFFSETFROM:+0200 | |
TZOFFSETTO:+0100 | |
TZNAME:CET | |
DTSTART:19701025T030000 | |
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU | |
END:STANDARD | |
END:VTIMEZONE""") | |
for l in j: | |
nextdt = (datetime.datetime.strptime(l['dt'], "%Y%m%d") + datetime.timedelta(days=1)).strftime("%Y%m%d") | |
tpl = f"""\ | |
BEGIN:VEVENT | |
DTSTAMP:20210119T201507Z | |
UID:{uuid4()} | |
DTSTART;VALUE=DATE:{l['dt']} | |
DTEND;VALUE=DATE:{nextdt} | |
SUMMARY:{l['afval']} | |
END:VEVENT""" | |
print(tpl) | |
print("END:VCALENDAR") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment