Mailing List Archive

python/nondist/sandbox/datetime datetime.py,1.65,1.66 test_both.py,1.8,1.9 test_cdatetime.py,1.10,1.11 test_datetime.py,1.50,1.51
Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory sc8-pr-cvs1:/tmp/cvs-serv8408

Modified Files:
datetime.py test_both.py test_cdatetime.py test_datetime.py
Log Message:
Moved test_isoformat into test_both. This was complicated in that
test_datetime expected a blank to be used as the date-time separator,
but test_cdatetime expected 'T'. After discussion with Fred, Guido,
and JimF, 'T' was the winner. So changed the Python implementation to
match. Also added a one-liner check that str(datetime) uses a blank.


Index: datetime.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v
retrieving revision 1.65
retrieving revision 1.66
diff -C2 -d -r1.65 -r1.66
*** datetime.py 25 Nov 2002 21:09:05 -0000 1.65
--- datetime.py 26 Nov 2002 18:03:19 -0000 1.66
***************
*** 1205,1209 ****
# ISO formats including time

! def isoformat(self, sep=' '):
"""Return the time formatted according to ISO.

--- 1205,1209 ----
# ISO formats including time

! def isoformat(self, sep='T'):
"""Return the time formatted according to ISO.

***************
*** 1212,1216 ****

Optional argument sep specifies the separator between date and
! time, default ' ' (use 'T' for strict ISO conformance).
"""
return "%04d-%02d-%02d%c%02d:%02d:%02d.%06d" % (
--- 1212,1216 ----

Optional argument sep specifies the separator between date and
! time, default 'T'.
"""
return "%04d-%02d-%02d%c%02d:%02d:%02d.%06d" % (

Index: test_both.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_both.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** test_both.py 26 Nov 2002 17:36:56 -0000 1.8
--- test_both.py 26 Nov 2002 18:03:23 -0000 1.9
***************
*** 403,406 ****
--- 403,414 ----
self.assertEqual(dt, dt2)

+ def test_isoformat(self):
+ t = self.theclass(2, 3, 2, 4, 5, 1, 123)
+ self.assertEqual(t.isoformat(), "0002-03-02T04:05:01.000123")
+ self.assertEqual(t.isoformat('T'), "0002-03-02T04:05:01.000123")
+ self.assertEqual(t.isoformat(' '), "0002-03-02 04:05:01.000123")
+ # str is ISO format with the separator forced to a blank.
+ self.assertEqual(str(t), "0002-03-02 04:05:01.000123")
+



Index: test_cdatetime.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_cdatetime.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** test_cdatetime.py 26 Nov 2002 17:31:20 -0000 1.10
--- test_cdatetime.py 26 Nov 2002 18:03:24 -0000 1.11
***************
*** 87,96 ****
self.assertEqual(L, iso_long_years)

- def test_isoformat(self):
- t = self.theclass(2, 3, 2, 4, 5, 1, 123)
- self.assertEqual(t.isoformat(), "0002-03-02T04:05:01.000123")
- self.assertEqual(t.isoformat('T'), "0002-03-02T04:05:01.000123")
- self.assertEqual(t.isoformat(' '), "0002-03-02 04:05:01.000123")
-
def test_weekday(self):
for i in range(7):
--- 87,90 ----

Index: test_datetime.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v
retrieving revision 1.50
retrieving revision 1.51
diff -C2 -d -r1.50 -r1.51
*** test_datetime.py 26 Nov 2002 17:31:21 -0000 1.50
--- test_datetime.py 26 Nov 2002 18:03:24 -0000 1.51
***************
*** 355,364 ****
self.assertRaises(TypeError, lambda: i-a)

- def test_isoformat(self):
- t = self.theclass(2, 3, 2, 4, 5, 1, 123)
- self.assertEqual(t.isoformat(), "0002-03-02 04:05:01.000123")
- self.assertEqual(t.isoformat('T'), "0002-03-02T04:05:01.000123")
- self.assertEqual(t.isoformat(' '), "0002-03-02 04:05:01.000123")
-
def test_tmxxx(self):
from datetime import tmxxx
--- 355,358 ----