summaryrefslogtreecommitdiffstats
path: root/Doc/lib/libdatetime.tex
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2002-12-25 07:40:55 (GMT)
committerTim Peters <tim.peters@gmail.com>2002-12-25 07:40:55 (GMT)
commit80475bb4d21d1e5ddbb9eb0042adb1113052b38a (patch)
treea76d25afddde0b216df8832174d3866d008f5e9b /Doc/lib/libdatetime.tex
parent6578dc925ff0a7953ae50c7ac41a81b0bd54762e (diff)
downloadcpython-80475bb4d21d1e5ddbb9eb0042adb1113052b38a.zip
cpython-80475bb4d21d1e5ddbb9eb0042adb1113052b38a.tar.gz
cpython-80475bb4d21d1e5ddbb9eb0042adb1113052b38a.tar.bz2
Implemented datetime.astimezone() and datetimetz.astimezone().
Diffstat (limited to 'Doc/lib/libdatetime.tex')
-rw-r--r--Doc/lib/libdatetime.tex22
1 files changed, 22 insertions, 0 deletions
diff --git a/Doc/lib/libdatetime.tex b/Doc/lib/libdatetime.tex
index f29db5b..1adbc8e 100644
--- a/Doc/lib/libdatetime.tex
+++ b/Doc/lib/libdatetime.tex
@@ -601,6 +601,11 @@ Instance methods:
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 @@ Instance methods:
\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}