Created
March 26, 2018 15:02
-
-
Save eiriks/287ce3fd4836dc8dc71aff6db6ea9a46 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
from ics import Calendar | |
import requests | |
url = "https://www.kayaposoft.com/enrico/ics/v2.0?country=nor&fromDate=01-01-2012&toDate=31-12-2028®ion=&holidayType=public_holiday&lang=no" | |
r = requests.get(url) | |
c = Calendar(r.text) | |
d = {} | |
d["events"] = [] | |
# Format I want: | |
# {"description": "event 1", "start_time": 1513641600000, "end_time": 1513728000000}, | |
# weired dateformat --> arrow? http://arrow.readthedocs.io/en/latest/ | |
for e in c.events: | |
d["events"].append({"description": e.name, "start_time": e.begin.isoformat(), "end_time": e.end.isoformat()}) | |
# need dates in ISO 8601 (is that what the example is in..?) | |
print(d) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment