[Python-checkins] python/nondist/sandbox/datetime doc.txt,1.22,1.23 obj_datetime.c,1.29,1.30 test_both.py,1.47,1.48 test_datetime.py,1.54,1.55
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Fri, 06 Dec 2002 21:33:47 -0800
Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory sc8-pr-cvs1:/tmp/cvs-serv4986
Modified Files:
doc.txt obj_datetime.c test_both.py test_datetime.py
Log Message:
Implement etc datetime.date(). The portion of test_datetime.py testing
this has been moved into test_both.py.
Index: doc.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/doc.txt,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** doc.txt 6 Dec 2002 21:03:07 -0000 1.22
--- doc.txt 7 Dec 2002 05:33:44 -0000 1.23
***************
*** 444,447 ****
--- 444,450 ----
Instance methods:
+ - date()
+ Return new date object with same year, month and day.
+
- 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.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** obj_datetime.c 7 Dec 2002 03:12:57 -0000 1.29
--- obj_datetime.c 7 Dec 2002 05:33:45 -0000 1.30
***************
*** 482,485 ****
--- 482,493 ----
}
+ static PyObject *
+ datetime_getdate(PyDateTime_DateTime *self)
+ {
+ return new_date((int)GET_YEAR(self),
+ (int)GET_MONTH(self),
+ (int)GET_DAY(self));
+ }
+
/* Pickle support. Quite a maze! */
***************
*** 580,583 ****
--- 588,594 ----
{"timetuple", (PyCFunction)datetime_timetuple, METH_NOARGS,
"Return time tuple, compatible with time.localtime()."},
+
+ {"date", (PyCFunction)datetime_getdate, METH_NOARGS,
+ "Return date object with same year, month and day."},
{"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.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** test_both.py 7 Dec 2002 02:12:31 -0000 1.47
--- test_both.py 7 Dec 2002 05:33:45 -0000 1.48
***************
*** 1113,1116 ****
--- 1113,1122 ----
"12 31 04 33 22 06 366")
+ def test_extract(self):
+ 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))
+
def test_suite():
allsuites = [unittest.makeSuite(klass, 'test')
Index: test_datetime.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v
retrieving revision 1.54
retrieving revision 1.55
diff -C2 -d -r1.54 -r1.55
*** test_datetime.py 4 Dec 2002 23:08:49 -0000 1.54
--- test_datetime.py 7 Dec 2002 05:33:45 -0000 1.55
***************
*** 194,198 ****
def test_extract(self):
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))
--- 194,199 ----
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))