summaryrefslogtreecommitdiffstats
path: root/Lib/datetime.py
diff options
context:
space:
mode:
authorAlexander Belopolsky <abalkin@users.noreply.github.com>2018-06-08 23:22:33 (GMT)
committerGitHub <noreply@github.com>2018-06-08 23:22:33 (GMT)
commitbcb032e4acdebc043a7659a06e6037fe71020860 (patch)
tree07c50dcbb30667ccb9110fc8a332da17b73b274d /Lib/datetime.py
parent4c3e39f61c6a759aa1370497ea3597f3564f9da0 (diff)
downloadcpython-bcb032e4acdebc043a7659a06e6037fe71020860.zip
cpython-bcb032e4acdebc043a7659a06e6037fe71020860.tar.gz
cpython-bcb032e4acdebc043a7659a06e6037fe71020860.tar.bz2
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.
Diffstat (limited to 'Lib/datetime.py')
-rw-r--r--Lib/datetime.py15
1 files changed, 4 insertions, 11 deletions
diff --git a/Lib/datetime.py b/Lib/datetime.py
index 8fa18a7..5e9aab9 100644
--- a/Lib/datetime.py
+++ b/Lib/datetime.py
@@ -1759,17 +1759,10 @@ class datetime(date):
ts = (self - _EPOCH) // timedelta(seconds=1)
localtm = _time.localtime(ts)
local = datetime(*localtm[:6])
- try:
- # Extract TZ data if available
- gmtoff = localtm.tm_gmtoff
- zone = localtm.tm_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
+ # Extract TZ data
+ gmtoff = localtm.tm_gmtoff
+ zone = localtm.tm_zone
+ return timezone(timedelta(seconds=gmtoff), zone)
def astimezone(self, tz=None):
if tz is None: