Comment 2 for bug 80055

Revision history for this message
Marius Gedminas (mgedmin) wrote :

Also, beware of using a_datetime.replace(tzinfo=foo) or datetime.combine(a_date,
time(tzinfo=foo)) -- it will give incorrect results:

  >>> vilnius = pytz.timezone('Europe/Vilnius')
  >>> datetime.datetime(2005, 9, 26, 20, 0, tzinfo=vilnius)
datetime.datetime(2005, 9, 26, 20, 0, tzinfo=<DstTzInfo 'Europe/Vilnius'
WMT+1:24:00 STD>)
  >>> print _.astimezone(pytz.utc)
  2005-09-26 18:36:00+00:00

Use tzinfo.localize(naive_datetime) instead.

I have found a lot of places in src/schooltool/app/browser/cal.py that might be
incorrect -- they will need unit tests for corner cases.

I also do not trust parse_timetz in src/schooltool/calendar/utils.py. Since it
is not used, I suggest removing it.