summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2003-01-02 19:35:54 (GMT)
committerTim Peters <tim.peters@gmail.com>2003-01-02 19:35:54 (GMT)
commit710fb1548ab43bcddc105c41b139b6328962de01 (patch)
tree7047ed7c552cb5cc43517e5b06dfbc7dee038a36 /Doc
parent0123139d665c02fa731511d32a31724137c8eca0 (diff)
downloadcpython-710fb1548ab43bcddc105c41b139b6328962de01.zip
cpython-710fb1548ab43bcddc105c41b139b6328962de01.tar.gz
cpython-710fb1548ab43bcddc105c41b139b6328962de01.tar.bz2
astimezone() internals: if utcoffset() returns a duration, complain if
dst() returns None (instead of treating that as 0).
Diffstat (limited to 'Doc')
-rw-r--r--Doc/lib/libdatetime.tex32
1 files changed, 19 insertions, 13 deletions
diff --git a/Doc/lib/libdatetime.tex b/Doc/lib/libdatetime.tex
index 72f4ed9..60fa678 100644
--- a/Doc/lib/libdatetime.tex
+++ b/Doc/lib/libdatetime.tex
@@ -893,21 +893,14 @@ implement all of them.
return CONSTANT # fixed-offset class
return CONSTANT + self.dst(dt) # daylight-aware class
\end{verbatim}
-\end{methoddesc}
-\begin{methoddesc}{tzname}{self, dt}
- Return the timezone name corresponding to the \class{datetime} represented
- by \var{dt}, as a string. Nothing about string names is defined by the
- \module{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
- \code{None} if a string name isn't known. Note that this is a method
- rather than a fixed string primarily because some \class{tzinfo} objects
- will wish to return different names depending on the specific value
- of \var{dt} passed, especially if the \class{tzinfo} class is
- accounting for daylight time.
+ If \method{utcoffset()} does not return \code{None},
+ \method{dst()} should not return \code{None} either.
+
+
\end{methoddesc}
+
\begin{methoddesc}{dst}{self, dt}
Return the daylight savings time (DST) adjustment, in minutes east of
UTC, or \code{None} if DST information isn't known. Return \code{0} if
@@ -937,6 +930,19 @@ implement all of them.
but cannot detect violations; it's the programmer's responsibility to
ensure it.
+\begin{methoddesc}{tzname}{self, dt}
+ Return the timezone name corresponding to the \class{datetime} represented
+ by \var{dt}, as a string. Nothing about string names is defined by the
+ \module{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
+ \code{None} if a string name isn't known. Note that this is a method
+ rather than a fixed string primarily because some \class{tzinfo} objects
+ will wish to return different names depending on the specific value
+ of \var{dt} passed, especially if the \class{tzinfo} class is
+ accounting for daylight time.
+\end{methoddesc}
+
\end{methoddesc}
These methods are called by a \class{datetimetz} or \class{timetz} object,
@@ -1379,7 +1385,7 @@ Instance methods:
\begin{verbatim}
>>> from datetime import *
>>> class TZ(tzinfo):
-... def utcoffset(self, dt): return -399
+... def utcoffset(self, dt): return timedelta(minutes=-399)
...
>>> datetimetz(2002, 12, 25, tzinfo=TZ()).isoformat(' ')
'2002-12-25 00:00:00-06:39'