[Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.35,1.36

Tim Peters tim_one@users.sourceforge.net
2002年3月03日 18:43:58 -0800


Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory usw-pr-cvs1:/tmp/cvs-serv18830
Modified Files:
	datetime.py 
Log Message:
datetime.__add__(): When adding a float, let the careful fp code in
timedelta.__add__ handle it instead. Since floating-point code is
always wrong <0.5 wink>, duplication of fp code should be avoided at
almost any cost.
Index: datetime.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** datetime.py	4 Mar 2002 02:25:28 -0000	1.35
--- datetime.py	4 Mar 2002 02:43:56 -0000	1.36
***************
*** 672,678 ****
 return self + timedelta(0, other)
 elif isinstance(other, float):
! ss, us = divmod(other*1e6, 1e6)
! d, ss = divmod(ss, 24*3600)
! return self + timedelta(int(d), int(ss), int(round(us)))
 return NotImplemented
 
--- 672,676 ----
 return self + timedelta(0, other)
 elif isinstance(other, float):
! return self + (timedelta(0) + other)
 return NotImplemented
 

AltStyle によって変換されたページ (->オリジナル) /