See datetime.tzinfo.fromutc
(self, dt)
| 191 | _tzinfos[inf] = self.__class__(inf, _tzinfos) |
| 192 | |
| 193 | def fromutc(self, dt): |
| 194 | '''See datetime.tzinfo.fromutc''' |
| 195 | if (dt.tzinfo is not None and |
| 196 | getattr(dt.tzinfo, '_tzinfos', None) is not self._tzinfos): |
| 197 | raise ValueError('fromutc: dt.tzinfo is not self') |
| 198 | dt = dt.replace(tzinfo=None) |
| 199 | idx = max(0, bisect_right(self._utc_transition_times, dt) - 1) |
| 200 | inf = self._transition_info[idx] |
| 201 | return (dt + inf[0]).replace(tzinfo=self._tzinfos[inf]) |
| 202 | |
| 203 | def normalize(self, dt): |
| 204 | '''Correct the timezone information on the given datetime |