Mercurial > cpython-lru_cache-weakref
diff Doc/lib/libdatetime.tex @ 27034:dc33d027645a legacy-trunk
astimezone() internals: if utcoffset() returns a duration, complain if
dst() returns None (instead of treating that as 0).
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Thu, 02 Jan 2003 19:35:54 +0000 |
| parents | 4579e83c663b |
| children | 99df0e52f634 |
line wrap: on
line diff
--- a/Doc/lib/libdatetime.tex Thu Jan 02 19:10:19 2003 +0000 +++ b/Doc/lib/libdatetime.tex Thu Jan 02 19:35:54 2003 +0000 @@ -893,20 +893,13 @@ return CONSTANT # fixed-offset class return CONSTANT + self.dst(dt) # daylight-aware class \end{verbatim} + + If \method{utcoffset()} does not return \code{None}, + \method{dst()} should not return \code{None} either. + + \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. -\end{methoddesc} \begin{methoddesc}{dst}{self, dt} Return the daylight savings time (DST) adjustment, in minutes east of @@ -937,6 +930,19 @@ 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 @@ \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'
