pyhthon error triggered by calendar.occurrences

(this is not ‘mission critical’ for us, so I’m writing here instead of opening a ticket)

hello, I’m trying to iterate over events of a specific day in a users calendar, like so

day_start = datetime.strptime('2018-01-01', '%Y-%m-%d')
day_end = datetime.strptime('2018-01-31', '%Y-%m-%d')

server  = kopano.Server(...)
calendar = server.user(...).store.calendar
for item in calendar.occurrences(day_start, day_end):
  # do something

the error I’m getting is:

Traceback (most recent call last):
  File "", line 52, in <module>
    for item in calendar.occurrences(start_time, end_time):
  File "/usr/lib/python2.7/dist-packages/kopano/", line 390, in occurrences
    for occurrence in self.item(entryid).occurrences(start, end):
  File "/usr/lib/python2.7/dist-packages/kopano/", line 103, in occurrences
    for occ in self.recurrence.occurrences(start=start, end=end):
  File "/usr/lib/python2.7/dist-packages/kopano/", line 914, in occurrences
    recurrences = recurrences.between(_utils._from_gmt(start, tz), _utils._from_gmt(end, tz))
  File "/usr/lib/python2.7/dist-packages/kopano/", line 202, in _from_gmt
    return date - datetime.timedelta(minutes=_get_timezone(date, tz_data))
  File "/usr/lib/python2.7/dist-packages/kopano/", line 188, in _get_timezone
    dst = _in_dst(date, dststartmonth, dststartweek, dststarthour, dstendmonth, dstendweek, dstendhour)
  File "/usr/lib/python2.7/dist-packages/kopano/", line 164, in _in_dst
    dststart = datetime.datetime(date.year, dststartmonth, 1) + \
ValueError: month must be in 1..12

I’m on latest kopano supported/stable from the debian repositories

sorry for the late reply.

we recently added a check to 8.6 for when dststartmonth==0, so here it almost has to be larger than 12… :S

would it be possible to give us the value of the local variable ‘tz_data’, as it’s possibly corrupted?

I usually do this by copying /usr/lib/…/kopano locally, and adding a print statement in there.

you could also print(self.subject, self.start) in, line 102 or so, to check out which appointment we are dealing with.

PS you can also use datetime(2018, 1, 2) if you’re not aware, so no need for strptime

PS2 user.calendar can also be used instead of (and anything else this way which is not ambiguous)