commit
This commit is contained in:
parent
12cbf9bb45
commit
a35314edd9
15
main.py
15
main.py
@ -3,6 +3,8 @@ import json
|
||||
from icalendar import Calendar, Event, vCalAddress, vText
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
def utc_to_time(naive, timezone="Europe/Istanbul"):
|
||||
return naive.replace(tzinfo=pytz.utc).astimezone(pytz.timezone(timezone))
|
||||
|
||||
cal = Calendar()
|
||||
cal.add('prodid', '-//Codam Events//Duinvoetje.nl//')
|
||||
@ -16,10 +18,11 @@ for entry in response.json():
|
||||
event = entry['event']
|
||||
ical_event.add('uid', event['id'])
|
||||
ical_event.add('dtstamp', datetime.now())
|
||||
ical_event.add('name', event['name'])
|
||||
ical_event.add('summary', event['name'])
|
||||
ical_event.add('description', event['description'])
|
||||
ical_event.add('dtstart', datetime.fromisoformat(event['begin_at'].split('.')[0]))
|
||||
ical_event.add('dtend', datetime.fromisoformat(event['end_at'].split('.')[0]))
|
||||
ical_event.add('dtstart',
|
||||
utc_to_time(datetime.fromisoformat(event['begin_at'].split('.')[0])), "Europe/Amsterdam")
|
||||
ical_event.add('dtend', utc_to_time(datetime.fromisoformat(event['end_at'].split('.')[0])), "Europe/Amsterdam")
|
||||
ical_event.add('location', event['location'])
|
||||
cal.add_component(ical_event)
|
||||
|
||||
@ -29,10 +32,10 @@ for entry in response2.json():
|
||||
event = entry
|
||||
ical_event.add('uid', event['id'])
|
||||
ical_event.add('dtstamp', datetime.now())
|
||||
ical_event.add('name', "Evaluation" )
|
||||
ical_event.add('summary', "Evaluation:\n" + event['corrector']['login'] + "->" + event['correcteds'][0]['login'] )
|
||||
ical_event.add('description', event['corrector']['login'] + " will evaluate " + event['correcteds'][0]['login'])
|
||||
ical_event.add('dtstart', datetime.fromisoformat(event['begin_at'].split('.')[0]))
|
||||
ical_event.add('dtend', datetime.fromisoformat(event['begin_at'].split('.')[0]) + timedelta(minutes=30))
|
||||
ical_event.add('dtstart', utc_to_time(datetime.fromisoformat(event['begin_at'].split('.')[0])), "Europe/Amsterdam")
|
||||
ical_event.add('dtend', utc_to_time(datetime.fromisoformat(event['begin_at'].split('.')[0]) + timedelta(minutes=30)), "Europe/Amsterdam")
|
||||
ical_event.add('location', "Codam Campus")
|
||||
cal.add_component(ical_event)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user