[Python-checkins] python/nondist/sandbox/datetime datetime.py,1.130,1.131 doc.txt,1.75,1.76
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Tue, 31 Dec 2002 07:56:34 -0800
Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory sc8-pr-cvs1:/tmp/cvs-serv25945
Modified Files:
datetime.py doc.txt
Log Message:
Inlined a timezone conversion routine that turned out to be called only
once. Updated the docs. The hoped-for treatment of DST endcases
remains unclear.
Index: datetime.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v
retrieving revision 1.130
retrieving revision 1.131
diff -C2 -d -r1.130 -r1.131
*** datetime.py 31 Dec 2002 05:58:02 -0000 1.130
--- datetime.py 31 Dec 2002 15:56:31 -0000 1.131
***************
*** 1618,1646 ****
"inconsistent results; cannot convert")
- def _finish_astimezone(self, other, otoff):
- # If this is the first hour of DST, it may be a local time that
- # doesn't make sense on the local clock, in which case the naive
- # hour before it (in standard time) is equivalent and does make
- # sense on the local clock. So force that.
- alt = other - _HOUR
- altoff = alt.utcoffset()
- if altoff is None:
- self._inconsistent_utcoffset_error()
- # Are alt and other really the same time? alt == other iff
- # alt - altoff == other - otoff, iff
- # (other - _HOUR) - altoff = other - otoff, iff
- # otoff - altoff == _HOUR
- diff = otoff - altoff
- if diff == _HOUR:
- return alt # use the local time that makes sense
-
- # There's still a problem with the unspellable (in local time)
- # hour after DST ends.
- if self == other:
- return other
- # Else there's no way to spell self in zone other.tz.
- raise ValueError("astimezone(): the source datetimetz can't be "
- "expressed in the target timezone's local time")
-
def astimezone(self, tz):
_check_tzinfo_arg(tz)
--- 1618,1621 ----
***************
*** 1679,1683 ****
if otoff is None:
self._inconsistent_utcoffset_error()
! return self._finish_astimezone(other, otoff)
def isoformat(self, sep='T'):
--- 1654,1682 ----
if otoff is None:
self._inconsistent_utcoffset_error()
!
! # If this is the first hour of DST, it may be a local time that
! # doesn't make sense on the local clock, in which case the naive
! # hour before it (in standard time) is equivalent and does make
! # sense on the local clock. So force that.
! alt = other - _HOUR
! altoff = alt.utcoffset()
! if altoff is None:
! self._inconsistent_utcoffset_error()
! # Are alt and other really the same time? alt == other iff
! # alt - altoff == other - otoff, iff
! # (other - _HOUR) - altoff = other - otoff, iff
! # otoff - altoff == _HOUR
! diff = otoff - altoff
! if diff == _HOUR:
! return alt # use the local time that makes sense
!
! # There's still a problem with the unspellable (in local time)
! # hour after DST ends.
! if self == other:
! return other
! # Else there's no way to spell self in zone other.tz.
! raise ValueError("astimezone(): the source datetimetz can't be "
! "expressed in the target timezone's local time")
!
def isoformat(self, sep='T'):
Index: doc.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/doc.txt,v
retrieving revision 1.75
retrieving revision 1.76
diff -C2 -d -r1.75 -r1.76
*** doc.txt 30 Dec 2002 19:43:21 -0000 1.75
--- doc.txt 31 Dec 2002 15:56:31 -0000 1.76
***************
*** 3,8 ****
- The Python implementation is missing docstrings in many places.
- - LaTeXize the docs.
-
CLOSED
--- 3,6 ----
***************
*** 834,840 ****
tzinfo methods interpret dt as being in local time, and not need to worry
about objects in other timezones.
- XXX That isn't always true yet: datetimetz.astimezone(tz) can pass
- XXX a datetimetz with a "foreign" tzinfo to a self.tzinfo method. This
- XXX needs to be repaired.
Example tzinfo classes:
--- 832,835 ----
***************
*** 1161,1169 ****
tz.utcoffset(self) does not return None, the date and time fields
are adjusted so that the result is local time in timezone tz,
! representing the same UTC time as self. self.astimezone(tz) is then
! equivalent to
! (self - (self.utcoffset() - tz.utcoffset(self)).replace(tzinfo=tz)
! where the result of tz.uctcoffset(self) is coerced to a timedelta if
! needed.
- timetuple()
--- 1156,1164 ----
tz.utcoffset(self) does not return None, the date and time fields
are adjusted so that the result is local time in timezone tz,
! representing the same UTC time as self.
! XXX The treatment of endcases remains unclear: for DST-aware
! XXX classes, one hour per year has two spellings in local time, and
! XXX another hour has no spelling in local time.
!
- timetuple()