[Python-checkins] python/nondist/sandbox/datetime datetime.py,1.73,1.74
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Tue, 03 Dec 2002 13:50:24 -0800
Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory sc8-pr-cvs1:/tmp/cvs-serv9869
Modified Files:
datetime.py
Log Message:
Gave the Python timedelta implementation a 9-digit limitation on # of
days too. This in turn required reimplementing its __cmp__ method, as
subtraction of Python timedeltas can overflow now.
Index: datetime.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v
retrieving revision 1.73
retrieving revision 1.74
diff -C2 -d -r1.73 -r1.74
*** datetime.py 3 Dec 2002 21:42:02 -0000 1.73
--- datetime.py 3 Dec 2002 21:50:20 -0000 1.74
***************
*** 372,375 ****
--- 372,377 ----
self.__seconds = s
self.__microseconds = us
+ if abs(d) > 999999999:
+ raise OverflowError("timedelta # of days is too large: %d" % d)
def __repr__(self):
***************
*** 458,467 ****
raise TypeError, ("can't compare timedelta to %s instance" %
type(other).__name__)
! diff = self - other
! if diff.__days < 0:
! return -1
! if diff.__days == 0 == diff.__seconds == diff.__microseconds:
! return 0
! return 1
def __hash__(self):
--- 460,464 ----
raise TypeError, ("can't compare timedelta to %s instance" %
type(other).__name__)
! return cmp(self.__getstate__(), other.__getstate__())
def __hash__(self):