Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

we shouldn't push timezone-naive timestamps to the calendar server #258

Merged
merged 1 commit into from
Jan 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion caldav/lib/vcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def create_ical(ical_fragment=None, objtype=None, language="en_DK", **props):
if objtype is None:
objtype = "VEVENT"
component = icalendar.cal.component_factory[objtype]()
component.add("dtstamp", datetime.datetime.now())
component.add("dtstamp", datetime.datetime.now(tz=datetime.timezone.utc))
component.add("uid", uuid.uuid1())
my_instance.add_component(component)
else:
Expand All @@ -142,6 +142,9 @@ def create_ical(ical_fragment=None, objtype=None, language="en_DK", **props):
ical_fragment = None
for prop in props:
if props[prop] is not None:
if isinstance(props[prop], datetime.datetime) and not props[prop].tzinfo:
## We need to have a timezone! Assume UTC.
props[prop] = props[prop].astimezone(datetime.timezone.utc)
if prop in ("child", "parent"):
for value in props[prop]:
component.add(
Expand Down