summaryrefslogtreecommitdiffstats
path: root/Doc/lib/libdatetime.tex
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2003-01-23 20:53:10 (GMT)
committerTim Peters <tim.peters@gmail.com>2003-01-23 20:53:10 (GMT)
commit2a44a8d3320ee7bcf5d718b5bdac550c6d34db4c (patch)
tree7ac5d610e87d7a2b56e097e14525d9bc3182459f /Doc/lib/libdatetime.tex
parent10cadce41ec7b94aafc11b4f2c9cfb7587f5b81d (diff)
downloadcpython-2a44a8d3320ee7bcf5d718b5bdac550c6d34db4c.zip
cpython-2a44a8d3320ee7bcf5d718b5bdac550c6d34db4c.tar.gz
cpython-2a44a8d3320ee7bcf5d718b5bdac550c6d34db4c.tar.bz2
SF bug 660872: datetimetz constructors behave counterintuitively (2.3a1).
This gives much the same treatment to datetime.fromtimestamp(stamp, tz) as the last batch of checkins gave to datetime.now(tz): do "the obvious" thing with the tz argument instead of a senseless thing.
Diffstat (limited to 'Doc/lib/libdatetime.tex')
-rw-r--r--Doc/lib/libdatetime.tex29
1 files changed, 19 insertions, 10 deletions
diff --git a/Doc/lib/libdatetime.tex b/Doc/lib/libdatetime.tex
index b890024..058d6d5 100644
--- a/Doc/lib/libdatetime.tex
+++ b/Doc/lib/libdatetime.tex
@@ -534,26 +534,35 @@ Other constructors, all class methods:
\cfunction{gettimeofday()} function).
Else \var{tz} must be an instance of a class \class{tzinfo} subclass,
- and the current date and time are translated to \var{tz}'s time
+ and the current date and time are converted to \var{tz}'s time
zone. In this case the result is equivalent to
- \code{\var{tz}.fromutc(datetime.utcnow().replace(tzinfo=\var{tz})}.
+ \code{\var{tz}.fromutc(datetime.utcnow().replace(tzinfo=\var{tz}))}.
See also \method{today()}, \method{utcnow()}.
\end{methoddesc}
\begin{methoddesc}{utcnow}{}
Return the current UTC date and time, with \member{tzinfo} \code{None}.
- This is like \method{now()}, but returns the current UTC date and time,
+ This is like \method{now()}, but returns the current UTC date and time,
as a naive \class{datetime} object.
See also \method{now()}.
\end{methoddesc}
-\begin{methoddesc}{fromtimestamp}{timestamp}
- Return the local \class{datetime} corresponding to the \POSIX{}
- timestamp, such as is returned by \function{time.time()}. This
- may raise \exception{ValueError}, if the timestamp is out of the
- range of values supported by the platform C
- \cfunction{localtime()} function. It's common for this to be
- restricted to years in 1970 through 2038.
+\begin{methoddesc}{fromtimestamp}{timestamp, tz=None}
+ Return the local date and time corresponding to the \POSIX{}
+ timestamp, such as is returned by \function{time.time()}.
+ If optional argument \var{tz} is \code{None} or not specified, the
+ timestamp is converted to the platform's local date and time, and
+ the returned \class{datetime} object is naive.
+
+ Else \var{tz} must be an instance of a class \class{tzinfo} subclass,
+ and the timestamp is converted to \var{tz}'s time zone. In this case
+ the result is equivalent to
+ \code{\var{tz}.fromutc(datetime.utcfromtimestamp(\var{timestamp}).replace(tzinfo=\var{tz}))}.
+
+ \method{fromtimestamp()} may raise \exception{ValueError}, if the
+ timestamp is out of the range of values supported by the platform C
+ \cfunction{localtime()} or \cfunction(gmtime()} functions. It's common
+ for this to be restricted to years in 1970 through 2038.
Note that on non-POSIX systems that include leap seconds in their
notion of a timestamp, leap seconds are ignored by
\method{fromtimestamp()}, and then it's possible to have two timestamps