mirror of
https://github.com/python/cpython.git
synced 2025-10-07 23:51:16 +00:00
bpo-33810 Remove unused code from datetime.py. (GH-7549)
Since implementation of bpo-25283, the objects returned by time.localtime always have tm_zone and tm_gmtoff attributes. Remove code that anticipates their absence.
This commit is contained in:
parent
4c3e39f61c
commit
bcb032e4ac
1 changed files with 4 additions and 11 deletions
|
@ -1759,17 +1759,10 @@ class datetime(date):
|
||||||
ts = (self - _EPOCH) // timedelta(seconds=1)
|
ts = (self - _EPOCH) // timedelta(seconds=1)
|
||||||
localtm = _time.localtime(ts)
|
localtm = _time.localtime(ts)
|
||||||
local = datetime(*localtm[:6])
|
local = datetime(*localtm[:6])
|
||||||
try:
|
# Extract TZ data
|
||||||
# Extract TZ data if available
|
gmtoff = localtm.tm_gmtoff
|
||||||
gmtoff = localtm.tm_gmtoff
|
zone = localtm.tm_zone
|
||||||
zone = localtm.tm_zone
|
return timezone(timedelta(seconds=gmtoff), zone)
|
||||||
except AttributeError:
|
|
||||||
delta = local - datetime(*_time.gmtime(ts)[:6])
|
|
||||||
zone = _time.strftime('%Z', localtm)
|
|
||||||
tz = timezone(delta, zone)
|
|
||||||
else:
|
|
||||||
tz = timezone(timedelta(seconds=gmtoff), zone)
|
|
||||||
return tz
|
|
||||||
|
|
||||||
def astimezone(self, tz=None):
|
def astimezone(self, tz=None):
|
||||||
if tz is None:
|
if tz is None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue