Skip to content
Snippets Groups Projects
Commit 764effc6 authored by Yngve Levinsen's avatar Yngve Levinsen
Browse files

vacation: resulting ical imports to outlook

validated on https://icalendar.org/validator.html
parent d7b024bf
No related branches found
No related tags found
No related merge requests found
from icalendar import Calendar, Event
from datetime import datetime
import os
def create_event(summary, description, date, uid):
def create_event(summary, reduced, date, uid):
event=Event()
event['uid']=str(uid)
event['dtstart']=''.join(date.split('-'))
event['description']=description
if reduced.lower()=='office closed':
event['dtstart;value=date']=''.join(date.split('-'))
elif reduced.lower()=='reduced 3 hours':
event['dtstart']=''.join(date.split('-'))+'T140000Z'
event['dtend']=''.join(date.split('-'))+'T170000Z'
else:
event['dtstart']=''.join(date.split('-'))
event['dtstamp']=datetime.now().strftime('%Y%m%dT%H%M%SZ')
event['description']=', '.join([summary, reduced])
event['summary']=summary
event['X-MICROSOFT-CDO-BUSYSTATUS']='OOF'
return event
calendar_swe_all=Calendar()
calendar_swe_all.add('version', '2.0')
calendar_swe_all.add('prodid', "Yngve's Superscript")
calendar_eng_all=calendar_swe_all.copy()
i_swe_all=1
i_eng_all=1
......@@ -22,6 +32,7 @@ for f in os.listdir('.'):
calendar_swe=Calendar()
calendar_swe.add('version', '2.0')
calendar_swe.add('prodid', "Yngve's Superscript")
calendar_eng=calendar_swe.copy()
i_swe=1
......@@ -38,20 +49,20 @@ for f in os.listdir('.'):
desc_swe=lsp[1].split('/')[1].strip()
reduction=lsp[-1].strip()
event_swe=create_event(desc_swe, desc_swe+', '+reduction, date, i_swe)
event_swe=create_event(desc_swe, reduction, date, i_swe)
i_swe+=1
calendar_swe.add_component(event_swe)
event_eng=create_event(desc_eng, desc_eng+', '+reduction, date, i_eng)
event_eng=create_event(desc_eng, reduction, date, i_eng)
i_eng+=1
calendar_eng.add_component(event_eng)
if year>2016:
event_swe_all=create_event(desc_swe, desc_swe+', '+reduction, date, i_swe_all)
event_swe_all=create_event(desc_swe, reduction, date, i_swe_all)
i_swe_all+=1
calendar_swe_all.add_component(event_swe_all)
event_eng_all=create_event(desc_eng, desc_eng+', '+reduction, date, i_eng_all)
event_eng_all=create_event(desc_eng, reduction, date, i_eng_all)
i_eng_all+=1
calendar_eng_all.add_component(event_eng_all)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment