Upgraded PyTZ to 2014.10

This commit is contained in:
Bas Stottelaar
2015-01-27 22:03:18 +01:00
parent c5f67d070d
commit 1e2901810f
41 changed files with 595 additions and 1181 deletions
+9 -8
View File
@@ -142,7 +142,7 @@ class StaticTzInfo(BaseTzInfo):
def __reduce__(self):
# Special pickle to zone remains a singleton and to cope with
# database changes.
# database changes.
return pytz._p, (self.zone,)
@@ -369,13 +369,15 @@ class DstTzInfo(BaseTzInfo):
# hints to be passed in (such as the UTC offset or abbreviation),
# but that is just getting silly.
#
# Choose the earliest (by UTC) applicable timezone.
sorting_keys = {}
# Choose the earliest (by UTC) applicable timezone if is_dst=True
# Choose the latest (by UTC) applicable timezone if is_dst=False
# i.e., behave like end-of-DST transition
dates = {} # utc -> local
for local_dt in filtered_possible_loc_dt:
key = local_dt.replace(tzinfo=None) - local_dt.tzinfo._utcoffset
sorting_keys[key] = local_dt
first_key = sorted(sorting_keys)[0]
return sorting_keys[first_key]
utc_time = local_dt.replace(tzinfo=None) - local_dt.tzinfo._utcoffset
assert utc_time not in dates
dates[utc_time] = local_dt
return dates[[min, max][not is_dst](dates)]
def utcoffset(self, dt, is_dst=None):
'''See datetime.tzinfo.utcoffset
@@ -560,4 +562,3 @@ def unpickler(zone, utcoffset=None, dstoffset=None, tzname=None):
inf = (utcoffset, dstoffset, tzname)
tz._tzinfos[inf] = tz.__class__(inf, tz._tzinfos)
return tz._tzinfos[inf]