I met this when tried to update 'Due' and 'DTStart' fields of VTODOs from date to datetime and vice versa.
Behaviour is very strange (try to update date<>datetime, naive datetime <> timezoned datetime etc).
#!/usr/bin/env python3
# Test Date[time] fields of vobject
import datetime, vobject
def just_due(vcal: str):
for s in vcal.split():
if s.startswith('DUE'):
return s
# Stage 1: create vtodo with due:date
vobj = vobject.iCalendar()
vobj.add('vtodo')
vobj.vtodo.add("due").value = datetime.datetime.now().date()
s = vobj.serialize()
print(type(vobj.vtodo.due.value), just_due(s))
# Stage 2: change due: date>datetime
vobj = vobject.readOne(s)
now = datetime.datetime.now()
vobj.vtodo.due.value = now
s = vobj.serialize()
print(type(now), "=>", type(vobj.vtodo.due.value), just_due(s))
# Stage 3: read result
vobj = vobject.readOne(s)
print(type(vobj.vtodo.due.value))
I met this when tried to update 'Due' and 'DTStart' fields of VTODOs from date to datetime and vice versa. Behaviour is very strange (try to update date<>datetime, naive datetime <> timezoned datetime etc).
Result: