mirror of
https://github.com/python/cpython.git
synced 2025-12-10 11:00:14 +00:00
gh-83861: Fix datetime.astimezone() method (GH-101545)
This commit is contained in:
parent
d4aa8578b1
commit
2b1260c557
4 changed files with 29 additions and 2 deletions
|
|
@ -1965,6 +1965,11 @@ class datetime(date):
|
|||
def _local_timezone(self):
|
||||
if self.tzinfo is None:
|
||||
ts = self._mktime()
|
||||
# Detect gap
|
||||
ts2 = self.replace(fold=1-self.fold)._mktime()
|
||||
if ts2 != ts: # This happens in a gap or a fold
|
||||
if (ts2 > ts) == self.fold:
|
||||
ts = ts2
|
||||
else:
|
||||
ts = (self - _EPOCH) // timedelta(seconds=1)
|
||||
localtm = _time.localtime(ts)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue