diff Doc/lib/libdatetime.tex @ 26792:816b8ddccfe1 legacy-trunk

Implemented datetime.astimezone() and datetimetz.astimezone().
author Tim Peters <tim.peters@gmail.com>
date Wed, 25 Dec 2002 07:40:55 +0000
parents 2f28436060c4
children 2319d13d54f5
line wrap: on
line diff
--- a/Doc/lib/libdatetime.tex	Tue Dec 24 18:31:27 2002 +0000
+++ b/Doc/lib/libdatetime.tex	Wed Dec 25 07:40:55 2002 +0000
@@ -601,6 +601,11 @@
     Return a datetime with the same value, except for those fields given
     new values by whichever keyword arguments are specified.
 
+  - astimezone(tz)
+    Return a \class{datetimetz} with the same date and time fields, and
+    with \member{tzinfo} member \var{tz}.  \var{tz} must be an instance
+    of a \class{tzinfo} subclass.
+
   - timetuple()
     Return a 9-element tuple of the form returned by
     \function{time.localtime()}.
@@ -1083,6 +1088,23 @@
     \code{tzinfo=None} can be specified to create a naive datetimetz from
     an aware datetimetz.
 
+  - astimezone(tz)
+    Return a \class{datetimetz} with new tzinfo member \var{tz}.  \var{tz}
+    must be an instance of a \class{tzinfo} subclass.  If self is naive, or
+    if \code(tz.utcoffset(self)} returns \code{None},
+    \code{self.astimezone(tz)} is equivalent to
+    \code{self.replace(tzinfo=tz)}:  a new timezone object is attached
+    without any conversion of date or time fields.  If self is aware and
+    \code{tz.utcoffset(self)} does not return \code{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.  \code{self.astimezone(tz)}
+    is then equivalent to
+    \begin{verbatim}
+        (self - (self.utcoffset() - tz.utcoffset(self)).replace(tzinfo=tz)
+    \end{verbatim}
+    where the result of \code{tz.uctcoffset(self)} is converted to a
+    \class{timedelta} if it's an integer.
+
   - utcoffset()
     If \member{tzinfo} is \code{None}, returns \code{None}, else
     \code{tzinfo.utcoffset(self)} converted to a \class{timedelta}