bpo-33810 Remove unused code from datetime.py. (GH-7549) · python/cpython@bcb032e (original) (raw)

Original file line number Diff line number Diff line change
@@ -1759,17 +1759,10 @@ def _local_timezone(self):
1759 1759 ts = (self - _EPOCH) // timedelta(seconds=1)
1760 1760 localtm = _time.localtime(ts)
1761 1761 local = datetime(*localtm[:6])
1762 -try:
1763 -# Extract TZ data if available
1764 -gmtoff = localtm.tm_gmtoff
1765 -zone = localtm.tm_zone
1766 -except AttributeError:
1767 -delta = local - datetime(*_time.gmtime(ts)[:6])
1768 -zone = _time.strftime('%Z', localtm)
1769 -tz = timezone(delta, zone)
1770 -else:
1771 -tz = timezone(timedelta(seconds=gmtoff), zone)
1772 -return tz
1762 +# Extract TZ data
1763 +gmtoff = localtm.tm_gmtoff
1764 +zone = localtm.tm_zone
1765 +return timezone(timedelta(seconds=gmtoff), zone)
1773 1766
1774 1767 def astimezone(self, tz=None):
1775 1768 if tz is None: