2

Hi i am creating ics file for calendar invitation, as far as i see that if i dont put time zone some emails may become conflict, i have checked working ics files from zoom and i see that they put

BEGIN:VTIMEZONE
TZID:Turkey Standard Time
BEGIN:STANDARD
DTSTART:16010101T000000
TZOFFSETFROM:+0300
TZOFFSETTO:+0300
END:STANDARD
END:VTIMEZONE

now i translated this to code like

timezone = Timezone()
timezone.add('TZID','Turkey Standard Time')
timezoneStandard = TimezoneStandard()
timezoneStandard.add('TZOFFSETFROM', timedelta(hours=3))
timezoneStandard.add('TZOFFSETTO', timedelta(hours=3))
timezoneStandard.add('DTSTART','16010101T000000') <==== PROBLEM IS HERE
timezone.add_component(timezoneStandard)
cal.add_component(timezone)

But i dont know to translate 16010101T000000 , i am getting error You must use datetime, date, timedelta

hkn
  • 371
  • 1
  • 14

1 Answers1

1

This is ISO-8601, you can parse this for example with .isoparse [readthedocs] from the dateutil package [readthedocs].

You can install this, for example in your local environment with:

pip3 install dateutils

Then you can parse this with:

>>> from dateutil.parser import isoparse
>>> isoparse('16010101T000000')
datetime.datetime(1601, 1, 1, 0, 0)

So you can use this in your code with:

timezoneStandard.add('DTSTART', isoparse('16010101T000000'))
Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555