[Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.42,1.43 test_datetime.py,1.29,1.30

Guido van Rossum gvanrossum@users.sourceforge.net
Mon, 04 Mar 2002 11:39:40 -0800


Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory usw-pr-cvs1:/tmp/cvs-serv16311

Modified Files:
	datetime.py test_datetime.py 
Log Message:
Add min, max and resolution to datetime class.
This was proposed by s.keim in the Wiki.

Index: datetime.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** datetime.py	4 Mar 2002 18:56:10 -0000	1.42
--- datetime.py	4 Mar 2002 19:39:38 -0000	1.43
***************
*** 790,793 ****
--- 790,798 ----
  
  
+ datetime.min = datetime(1, 1, 1, tzoffset=0)
+ datetime.max = datetime(9999, 12, 31, 23, 59, 59, 999999, tzoffset=0)
+ datetime.resolution = timedelta(microseconds=1)
+ 
+ 
  def _isoweek1monday(year):
      # Helper to calculate the day number of the Monday starting week 1

Index: test_datetime.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** test_datetime.py	4 Mar 2002 19:09:12 -0000	1.29
--- test_datetime.py	4 Mar 2002 19:39:38 -0000	1.30
***************
*** 387,390 ****
--- 387,396 ----
              self.fail("Can't test utcctime()")
  
+     def test_resolution_info(self):
+         self.assert_(isinstance(datetime.min, datetime))
+         self.assert_(isinstance(datetime.max, datetime))
+         self.assert_(isinstance(datetime.resolution, timedelta))
+         self.assert_(datetime.max > datetime.min)
+ 
  def test_suite():
      s1 = unittest.makeSuite(TestDateTime, 'test')