Skip to content

Commit

Permalink
Merge pull request #15 from jesterpm/master
Browse files Browse the repository at this point in the history
Fix replies for all-day events
  • Loading branch information
marvinthepa authored Apr 12, 2022
2 parents 02b860c + f52875b commit cba522e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions mutt-ical.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,10 @@ def get_answer(invitation):
ans.add('vevent')

# just copy from invitation
for i in ["uid", "summary", "dtstart", "dtend", "organizer"]:
for i in ["uid", "summary", "dtstart", "dtend", "organizer", "vtimezone"]:
if i in invitation.vevent.contents:
ans.vevent.add(invitation.vevent.contents[i][0])

ans.vtimezone = invitation.vtimezone

# new timestamp
ans.vevent.add('dtstamp')
ans.vevent.dtstamp.value = datetime.utcnow().replace(
Expand All @@ -94,6 +92,12 @@ def openics(invitation_file):
invitation = vobject.readOne(f, ignoreUnreadable=True)
return invitation

def format_date(value):
if isinstance(value, datetime):
return value.astimezone(tz=None).strftime("%Y-%m-%d %H:%M %z")
else:
return value.strftime("%Y-%m-%d %H:%M %z")

def display(ical):
summary = ical.vevent.contents['summary'][0].value
if 'organizer' in ical.vevent.contents:
Expand Down Expand Up @@ -128,9 +132,9 @@ def display(ical):
sys.stdout.write(attendee.value.split(':')[1] + " <" + attendee.value.split(':')[1] + ">, ") #workaround for 'mailto:' in email
sys.stdout.write("\n")
if hasattr(ical.vevent, 'dtstart'):
print("Start:\t%s" % (ical.vevent.dtstart.value.astimezone(tz=None).strftime("%Y-%m-%d %H:%M %z"),))
print("Start:\t%s" % (format_date(ical.vevent.dtstart.value),))
if hasattr(ical.vevent, 'dtend'):
print("End:\t%s" % (ical.vevent.dtend.value.astimezone(tz=None).strftime("%Y-%m-%d %H:%M %z"),))
print("End:\t%s" % (format_date(ical.vevent.dtend.value),))
if locations:
sys.stdout.write("Location:\t")
for location in locations:
Expand Down

0 comments on commit cba522e

Please sign in to comment.