4 ms·
The actual check is for if time_in_minutes == tz_offset_in_minutes. The problem is that times are always positive, so this check doesn't work if the offset is n
by plorkyeran 13y ago
The actual check is for if time_in_minutes == tz_offset_in_minutes. The problem is that times are always positive, so this check doesn't work if the offset is negative. The correct implementation would be time_in_minutes == (tz_offset_in_minutes + minutes_in_day) % minutes_in_day.
- jessaustin 13y agoThanks for the info. I've confirmed this for myself now: class Offset(tzinfo): def __init__(self, offset): self.offset = offset def utcoffset(self, dt): return self.offset >>> bool(time(1, 0, tzinfo=Offset(timedelta(hours=1)))) False >>> bool(time(23, 0, tzinfo=Offset(timedelta(hours=-1)))) True Although this is kind of funny, because for time.hour, 23 and -1 should be the same thing: >>> bool(time(23, 0, tzinfo=Offset(timedelta(hours=23)))) False I'm convinced: legacy behavior is wrong and should be changed.