[Python-checkins] python/dist/src/Doc/lib libdatetime.tex,1.27,1.28 tzinfo-examples.py,1.1,1.2

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Thu, 02 Jan 2003 13:28:09 -0800


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

Modified Files:
	libdatetime.tex tzinfo-examples.py 
Log Message:
The tzinfo methods utcoffset() and dst() must return a timedelta object 
(or None) now.  In 2.3a1 they could also return an int or long, but that 
was an unhelpfully redundant leftover from an earlier version wherein 
they couldn't return a timedelta.  TOOWTDI.


Index: libdatetime.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdatetime.tex,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** libdatetime.tex	2 Jan 2003 19:35:53 -0000	1.27
--- libdatetime.tex	2 Jan 2003 21:28:07 -0000	1.28
***************
*** 232,247 ****
    \lineiii{\var{t1} = \var{t2} // \var{i}}
            {The floor is computed and the remainder (if any) is thrown away.}
!           {(2)}
    \lineiii{+\var{t1}}
            {Returns a \class{timedelta} object with the same value.}
!           {}
    \lineiii{-\var{t1}}
            {equivalent to \class{timedelta}(-\var{t1.days}, -\var{t1.seconds},
             -\var{t1.microseconds}),and to \var{t1}* -1.}
!           {(1)(3)}
    \lineiii{abs(\var{t})}
            {equivalent to +\var{t} when \code{t.days >= 0}, and to
!            -\var{t} when \code{t.days < 0}.}
!           {(1)}
  \end{tableiii}
  \noindent
--- 232,248 ----
    \lineiii{\var{t1} = \var{t2} // \var{i}}
            {The floor is computed and the remainder (if any) is thrown away.}
!           {(3)}
    \lineiii{+\var{t1}}
            {Returns a \class{timedelta} object with the same value.}
!           {(2)}
    \lineiii{-\var{t1}}
            {equivalent to \class{timedelta}(-\var{t1.days}, -\var{t1.seconds},
             -\var{t1.microseconds}),and to \var{t1}* -1.}
!           {(1)(4)}
    \lineiii{abs(\var{t})}
            {equivalent to +\var{t} when \code{t.days >= 0}, and to
!            -\var{t} when \code{t.days < 0}.
!            overflow.}
!           {(2)}
  \end{tableiii}
  \noindent
***************
*** 253,259 ****
  
  \item[(2)]
!   Division by 0 raises \exception{ZeroDivisionError}.
  
  \item[(3)]
    -\var{timedelta.max} is not representable as a \class{timedelta} object.
  \end{description}
--- 254,263 ----
  
  \item[(2)]
!   This is exact, and cannot overflow.
  
  \item[(3)]
+   Division by 0 raises \exception{ZeroDivisionError}.
+ 
+ \item[(4)]
    -\var{timedelta.max} is not representable as a \class{timedelta} object.
  \end{description}
***************
*** 884,892 ****
    \method{utcoffset()} should return their sum.  If the UTC offset
    isn't known, return \code{None}.  Else the value returned must be
!   an integer, in the range -1439 to 1439 inclusive (1440 = 24*60;
!   the magnitude of the offset must be less than one day), or a
!   \class{timedelta} object representing a whole number of minutes
!   in the same range.  Most implementations of \method{utcoffset()}
!   will probably look like one of these two:
  
  \begin{verbatim}
--- 888,895 ----
    \method{utcoffset()} should return their sum.  If the UTC offset
    isn't known, return \code{None}.  Else the value returned must be
!   a \class{timedelta} object specifying a whole number of minutes in the
!   range -1439 to 1439 inclusive (1440 = 24*60; the magnitude of the offset
!   must be less than one day).  Most implementations of
!   \method{utcoffset()} will probably look like one of these two:
  
  \begin{verbatim}
***************
*** 897,902 ****
      If \method{utcoffset()} does not return \code{None},
      \method{dst()} should not return \code{None} either.
- 
- 
  \end{methoddesc}
  
--- 900,903 ----
***************
*** 906,910 ****
    UTC, or \code{None} if DST information isn't known.  Return \code{0} if
    DST is not in effect.
!   If DST is in effect, return the offset as an integer or
    \class{timedelta} object (see \method{utcoffset()} for details).
    Note that DST offset, if applicable, has
--- 907,911 ----
    UTC, or \code{None} if DST information isn't known.  Return \code{0} if
    DST is not in effect.
!   If DST is in effect, return the offset as a
    \class{timedelta} object (see \method{utcoffset()} for details).
    Note that DST offset, if applicable, has

Index: tzinfo-examples.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/tzinfo-examples.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tzinfo-examples.py	23 Dec 2002 18:52:19 -0000	1.1
--- tzinfo-examples.py	2 Jan 2003 21:28:07 -0000	1.2
***************
*** 1,3 ****
! from datetime import tzinfo
  
  class UTC(tzinfo):
--- 1,5 ----
! from datetime import tzinfo, timedelta
! 
! ZERO = timedelta(0)
  
  class UTC(tzinfo):
***************
*** 5,9 ****
  
      def utcoffset(self, dt):
!         return 0
  
      def tzname(self, dt):
--- 7,11 ----
  
      def utcoffset(self, dt):
!         return ZERO
  
      def tzname(self, dt):
***************
*** 11,15 ****
  
      def dst(self, dt):
!         return 0
  
  class FixedOffset(tzinfo):
--- 13,17 ----
  
      def dst(self, dt):
!         return ZERO
  
  class FixedOffset(tzinfo):
***************
*** 27,32 ****
  
      def dst(self, dt):
!         # It depends on more than we know in an example.
!         return None # Indicate we don't know
  
  import time
--- 29,33 ----
  
      def dst(self, dt):
!         return ZERO
  
  import time
***************
*** 44,50 ****
      def utcoffset(self, dt):
          if self._isdst(dt):
!             return -time.timezone/60
          else:
!             return -time.altzone/60
  
      def tzname(self, dt):
--- 45,51 ----
      def utcoffset(self, dt):
          if self._isdst(dt):
!             return timedelta(seconds=-time.timezone)
          else:
!             return timedelta(seconds=-time.altzone)
  
      def tzname(self, dt):