[Zope3-checkins] CVS: Zope3/src/datetime - _datetime.py:1.16 doc.txt:1.8
Tim Peters
tim.one@comcast.net
Thu, 2 Jan 2003 14:27:45 -0500
Update of /cvs-repository/Zope3/src/datetime
In directory cvs.zope.org:/tmp/cvs-serv4901/src/datetime
Modified Files:
_datetime.py doc.txt
Log Message:
astimezone() internals: if utcoffset() returns a duration, complain if
dst() returns None (instead of treating that as 0).
=== Zope3/src/datetime/_datetime.py 1.15 => 1.16 ===
--- Zope3/src/datetime/_datetime.py:1.15 Thu Jan 2 12:48:44 2003
+++ Zope3/src/datetime/_datetime.py Thu Jan 2 14:27:12 2003
@@ -1637,7 +1637,8 @@
# pretty intricate proof.
otdst = other.dst()
if otdst is None:
- otdst = 0
+ raise ValueError("astimezone(): utcoffset() returned a duration "
+ "but dst() returned None")
total_added_to_other = otoff - otdst - myoff
if total_added_to_other:
other += total_added_to_other
@@ -1658,6 +1659,8 @@
total_added_to_other += delta
other += delta
otoff = other.utcoffset()
+ if otoff is None:
+ self._inconsistent_utcoffset_error()
##assert (other == self) == (otoff - myoff == total_added_to_other)
if otoff - myoff == total_added_to_other:
return other
=== Zope3/src/datetime/doc.txt 1.7 => 1.8 ===
--- Zope3/src/datetime/doc.txt:1.7 Wed Jan 1 15:56:20 2003
+++ Zope3/src/datetime/doc.txt Thu Jan 2 14:27:12 2003
@@ -791,16 +791,8 @@
return CONSTANT # fixed-offset class
return CONSTANT + self.dst(dt) # daylight-aware class
- - tzname(self, dt)
- Return the timezone name corresponding to the datetime represented
- by dt, as a string. Nothing about string names is defined by the
- datetime module, and there's no requirement that it mean anything
- in particular. For example, "GMT", "UTC", "-500", "-5:00", "EDT",
- "US/Eastern", "America/New York" are all valid replies. Return
- None if a string name isn't known. Note that this is a method
- rather than a fixed string primarily because some tzinfo objects
- will wish to return different names depending on the specific value
- of dt passed, especially if the tzinfo class is accounting for DST.
+ If utcoffset() does not return None, dst() should not return None
+ either.
- dst(self, dt)
Return the DST offset, in minutes east of UTC, or None if DST
@@ -825,6 +817,17 @@
time passed. The implementation of datetimetz.astimezone() relies on
this, but cannot detect violations; it's the programmer's
responsibility to ensure it.
+
+ - tzname(self, dt)
+ Return the timezone name corresponding to the datetime represented
+ by dt, as a string. Nothing about string names is defined by the
+ datetime module, and there's no requirement that it mean anything
+ in particular. For example, "GMT", "UTC", "-500", "-5:00", "EDT",
+ "US/Eastern", "America/New York" are all valid replies. Return
+ None if a string name isn't known. Note that this is a method
+ rather than a fixed string primarily because some tzinfo objects
+ will wish to return different names depending on the specific value
+ of dt passed, especially if the tzinfo class is accounting for DST.
These methods are called by a datetimetz or timetz object, in response to
their methods of the same names. A datetimetz object passes itself as the