[Python-checkins] python/nondist/sandbox/datetime doc.txt,1.27,1.28 obj_datetime.c,1.34,1.35 test_both.py,1.52,1.53 test_datetime.py,1.56,1.57

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Sat, 07 Dec 2002 12:24:48 -0800


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

Modified Files:
	doc.txt obj_datetime.c test_both.py test_datetime.py 
Log Message:
Implemented the datetime.datetime.time() extractor.


Index: doc.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/doc.txt,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** doc.txt	7 Dec 2002 19:57:21 -0000	1.27
--- doc.txt	7 Dec 2002 20:24:46 -0000	1.28
***************
*** 455,458 ****
--- 455,461 ----
      Return new date object with same year, month and day.
  
+   - time()
+     Return time object with same hour, minute, second and microsecond.
+ 
    - timetuple()
      Return a 9-element tuple of the form returned by time.localtime().

Index: obj_datetime.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/obj_datetime.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** obj_datetime.c	7 Dec 2002 19:51:18 -0000	1.34
--- obj_datetime.c	7 Dec 2002 20:24:46 -0000	1.35
***************
*** 491,497 ****
  datetime_getdate(PyDateTime_DateTime *self)
  {
! 	return new_date((int)GET_YEAR(self),
! 			(int)GET_MONTH(self),
! 			(int)GET_DAY(self));
  }
  
--- 491,506 ----
  datetime_getdate(PyDateTime_DateTime *self)
  {
! 	return new_date(GET_YEAR(self),
! 			GET_MONTH(self),
! 			GET_DAY(self));
! }
! 
! static PyObject *
! datetime_gettime(PyDateTime_DateTime *self)
! {
! 	return new_time(DATE_GET_HOUR(self),
! 			DATE_GET_MINUTE(self),
! 			DATE_GET_SECOND(self),
! 			DATE_GET_MICROSECOND(self));
  }
  
***************
*** 597,600 ****
--- 606,612 ----
  	{"date",   (PyCFunction)datetime_getdate, METH_NOARGS,
           "Return date object with same year, month and day."},
+ 
+ 	{"time",   (PyCFunction)datetime_gettime, METH_NOARGS,
+          "Return time object with same hour, minute, second and microsecond."},
  
  	{"ctime",       (PyCFunction)datetime_ctime,	METH_NOARGS,

Index: test_both.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_both.py,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -d -r1.52 -r1.53
*** test_both.py	7 Dec 2002 20:19:02 -0000	1.52
--- test_both.py	7 Dec 2002 20:24:46 -0000	1.53
***************
*** 1129,1134 ****
          dt = self.theclass(2002, 3, 4, 18, 45, 3, 1234)
          self.assertEqual(dt.date(), date(2002, 3, 4))
!         # Next line is in test_datetime now.
!         # self.assertEqual(dt.time(), time(18, 45, 3, 1234))
  
  class TestTime(unittest.TestCase):
--- 1129,1133 ----
          dt = self.theclass(2002, 3, 4, 18, 45, 3, 1234)
          self.assertEqual(dt.date(), date(2002, 3, 4))
!         self.assertEqual(dt.time(), time(18, 45, 3, 1234))
  
  class TestTime(unittest.TestCase):

Index: test_datetime.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v
retrieving revision 1.56
retrieving revision 1.57
diff -C2 -d -r1.56 -r1.57
*** test_datetime.py	7 Dec 2002 18:34:39 -0000	1.56
--- test_datetime.py	7 Dec 2002 20:24:46 -0000	1.57
***************
*** 80,89 ****
          self.assertEqual(dt, datetime(2002, 3, 4, 18, 45, 3, 1234))
  
-     def test_extract(self):
-         dt = self.theclass(2002, 3, 4, 18, 45, 3, 1234)
-         # Next line is in test_both now.
-         # self.assertEqual(dt.date(), date(2002, 3, 4))
-         self.assertEqual(dt.time(), time(18, 45, 3, 1234))
- 
  
  class FixedOffset(object):
--- 80,83 ----