@kovid, the change doesn't fix it. The problem seems to be that the pythong astimezone() method produces a different answer for dates before 1970, at least on Windows.
Please find attached a test program that demonstrates the difference. It is executed with calibre-debug. It calls qt_to_dt with 2 dates, one in 1969 and one in 1971. In the 1969 case it returns a UTC date. In the 1971 case it returns a local time zone date. I am in GMT and DST is True.
The output ofthe test program on my machine is:
Fri Jul 18 00:00:00 1969 UTC+01:00 converts to 1969-07-17 23:00:00+00:00
answer is in timezone GMT Standard Time
------------------
Sun Jul 18 00:00:00 1971 UTC+01:00 converts to 1971-07-18 00:00:00+01:00
answer is in timezone GMT Daylight Time
It is hard to believe that the python library is broken, but it sure looks like that.
@kovid, the change doesn't fix it. The problem seems to be that the pythong astimezone() method produces a different answer for dates before 1970, at least on Windows.
Please find attached a test program that demonstrates the difference. It is executed with calibre-debug. It calls qt_to_dt with 2 dates, one in 1969 and one in 1971. In the 1969 case it returns a UTC date. In the 1971 case it returns a local time zone date. I am in GMT and DST is True.
The output ofthe test program on my machine is:
Fri Jul 18 00:00:00 1969 UTC+01:00 converts to 1969-07-17 23:00:00+00:00
answer is in timezone GMT Standard Time
------------------
Sun Jul 18 00:00:00 1971 UTC+01:00 converts to 1971-07-18 00:00:00+01:00
answer is in timezone GMT Daylight Time
It is hard to believe that the python library is broken, but it sure looks like that.