[Python-checkins] python/dist/src/Doc/lib libdatetime.tex,1.7,1.8

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Tue, 24 Dec 2002 23:40:57 -0800


Update of /cvsroot/python/python/dist/src/Doc/lib
In directory sc8-pr-cvs1:/tmp/cvs-serv24666/python/Doc/lib

Modified Files:
	libdatetime.tex 
Log Message:
Implemented datetime.astimezone() and datetimetz.astimezone().


Index: libdatetime.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdatetime.tex,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** libdatetime.tex	24 Dec 2002 16:34:13 -0000	1.7
--- libdatetime.tex	25 Dec 2002 07:40:54 -0000	1.8
***************
*** 602,605 ****
--- 602,610 ----
      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
***************
*** 1083,1086 ****
--- 1088,1108 ----
      \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()