Skip to content

Instantly share code, notes, and snippets.

@eiriks
Created March 26, 2018 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eiriks/287ce3fd4836dc8dc71aff6db6ea9a46 to your computer and use it in GitHub Desktop.
Save eiriks/287ce3fd4836dc8dc71aff6db6ea9a46 to your computer and use it in GitHub Desktop.
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&region=&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