[pywin32-checkins] /hgroot/pywin32/pywin32: Backed out changeset: ba623bb65a7b
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <pyw...@li...> - 2012-05-13 21:42:57
|
changeset b8c62cf04c5a in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=b8c62cf04c5a summary: Backed out changeset: ba623bb65a7b diffstat: win32/Lib/win32timezone.py | 41 +---------------------------------------- 1 files changed, 1 insertions(+), 40 deletions(-) diffs (85 lines): diff -r 93b87a416b72 -r b8c62cf04c5a win32/Lib/win32timezone.py --- a/win32/Lib/win32timezone.py Sat May 12 13:46:28 2012 +1000 +++ b/win32/Lib/win32timezone.py Sun May 13 17:42:31 2012 -0400 @@ -202,8 +202,6 @@ datetime.datetime(2011, 11, 5, 19, 0, tzinfo=TimeZoneInfo('Pacific Standard Time')) Make sure the converted time is correct. ->>> tz_pac -TimeZoneInfo('Pacific Standard Time') >>> dt_pac = dt_hi.astimezone(tz_pac) >>> dt_pac.timetuple() time.struct_time(tm_year=2011, tm_mon=11, tm_mday=5, tm_hour=19, tm_min=0, tm_sec=0, tm_wday=5, tm_yday=309, tm_isdst=1) @@ -226,31 +224,13 @@ >>> (offset + dst_offset) == datetime.timedelta(hours=-7) True + Test offsets that occur right at the DST changeover >>> datetime.datetime.utcfromtimestamp(1320570000).replace( ... tzinfo=TimeZoneInfo.utc()).astimezone(tz_pac) datetime.datetime(2011, 11, 6, 1, 0, tzinfo=TimeZoneInfo('Pacific Standard Time')) -TimeZoneInfo now raises AmbiguousTimeError for ambiguous times -============================================================== - -Is 1:15 the first one, or the one after clocks were set back? ->>> ambiguous = datetime.datetime(2011, 11, 6, 1, 15) ->>> est = TimeZoneInfo('Eastern Standard Time') ->>> est.dst(ambiguous) -Traceback (most recent call last): -[...] -AmbiguousTimeError: 2011-11-06 01:15:00 ->>> est.utcoffset(ambiguous) -Traceback (most recent call last): -[...] -AmbiguousTimeError: 2011-11-06 01:15:00 - -However, if we're converting from UTC, it's not ambiguous. ->>> datetime.datetime(2011, 11, 6, 6, 0, tzinfo=TimeZoneInfo.utc()).astimezone(est) -datetime.datetime(2011, 11, 6, 1, 0, tzinfo=TimeZoneInfo('Eastern Standard Time')) """ - from __future__ import generators __author__ = 'Jason R. Coombs <ja...@ja...>' @@ -615,19 +595,6 @@ winInfo = self.getWinInfo(dt.year) return winInfo.bias + winInfo.daylight_bias - def fromutc(self, dt): - if dt.tzinfo is not self: - raise ValueError("tzinfo is not self") - # calculate the local time using the standard offset - tz_std = TimeZoneInfo(self.timeZoneName, fix_standard_time=True) - delta = tz_std.utcoffset(dt) - dt += delta - try: - dt += self.dst(dt) - except AmbiguousTimeError: - pass - return dt - def utcoffset(self, dt): "Calculates the utcoffset according to the datetime.tzinfo spec" if dt is None: return @@ -660,9 +627,6 @@ # if there's a standard_bias (which I suspect is always 0). dstStartAdj = dstStart + winInfo.standard_bias - if dstEndAdj <= dt < dstEnd or dstStartAdj <= dt < dstStart: - raise AmbiguousTimeError(dt) - if dstStart < dstEnd: in_dst = dstStartAdj <= dt < dstEndAdj else: @@ -841,9 +805,6 @@ GetSortedTimeZoneNames = deprecated(TimeZoneInfo.get_sorted_time_zone_names, 'GetSortedTimeZoneNames') # end backward compatibility -class AmbiguousTimeError(Exception): - pass - def utcnow(): """ Return the UTC time now with timezone awareness as enabled |