1515# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717#
18- # $Id: date.py,v 1.62 2004-03-24 03:07:51 richard Exp $
18+ # $Id: date.py,v 1.63 2004-03-24 04:57:25 richard Exp $
1919
2020"""Date, time and time interval handling.
2121"""
@@ -300,16 +300,20 @@ def dateDelta(self, other):
300300 d = diff / (24 * 60 * 60 )
301301 return Interval ((0 , 0 , d , H , M , S ), sign = sign )
302302
303- def __cmp__ (self , other ):
303+ def __cmp__ (self , other , int_seconds = 0 ):
304304 """Compare this date to another date."""
305305 if other is None :
306306 return 1
307- for attr in ('year' , 'month' , 'day' , 'hour' , 'minute' , 'second' ):
307+ for attr in ('year' , 'month' , 'day' , 'hour' , 'minute' ):
308308 if not hasattr (other , attr ):
309309 return 1
310310 r = cmp (getattr (self , attr ), getattr (other , attr ))
311311 if r : return r
312- return 0
312+ if not hasattr (other , 'second' ):
313+ return 1
314+ if int_seconds :
315+ return cmp (int (self .second ), int (other .second ))
316+ return cmp (self .second , other .second )
313317
314318 def __str__ (self ):
315319 """Return this date as a string in the yyyy-mm-dd.hh:mm:ss format."""
@@ -334,7 +338,7 @@ def pretty(self, format='%d %B %Y'):
334338 return str
335339
336340 def __repr__ (self ):
337- return '<Date %s>' % self .__str__ ( )
341+ return '<Date %s>' % self .formal ( sec = '%f' )
338342
339343 def local (self , offset ):
340344 """ Return this date as yyyy-mm-dd.hh:mm:ss in a local time zone.
0 commit comments