[Python-checkins] python/nondist/sandbox/datetime datetime.py,1.106,1.107 test_both.py,1.87,1.88
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Sun, 15 Dec 2002 08:35:57 -0800
- Previous message: [Python-checkins] python/dist/src/Python modsupport.c,2.62,2.63
- Next message: [Python-checkins] python/nondist/sandbox/datetime datetime.c,1.74,1.75 datetime.py,1.107,1.108 doc.txt,1.54,1.55 obj_datetimetz.c,1.24,1.25 test_both.py,1.88,1.89
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory sc8-pr-cvs1:/tmp/cvs-serv26330
Modified Files:
datetime.py test_both.py
Log Message:
datetimetz.isoformat(): This wasn't tested. Added a test. Simplified
the Python implementation of it.
Index: datetime.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v
retrieving revision 1.106
retrieving revision 1.107
diff -C2 -d -r1.106 -r1.107
*** datetime.py 15 Dec 2002 05:14:52 -0000 1.106
--- datetime.py 15 Dec 2002 16:35:55 -0000 1.107
***************
*** 1448,1461 ****
def isoformat(self, sep='T'):
s = super(datetimetz, self).isoformat(sep)
! if self.__tzinfo is not None:
! off = self.__tzinfo.utcoffset(self)
! if off is not None:
! if off < 0:
! sign = "-"
! off = -off
! else:
! sign = "+"
! hh, mm = divmod(off, 60)
! s = s + "%s%02d:%02d" % (sign, hh, mm)
return s
--- 1448,1460 ----
def isoformat(self, sep='T'):
s = super(datetimetz, self).isoformat(sep)
! off = self.utcoffset()
! if off is not None:
! if off < 0:
! sign = "-"
! off = -off
! else:
! sign = "+"
! hh, mm = divmod(off, 60)
! s += "%s%02d:%02d" % (sign, hh, mm)
return s
Index: test_both.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_both.py,v
retrieving revision 1.87
retrieving revision 1.88
diff -C2 -d -r1.87 -r1.88
*** test_both.py 15 Dec 2002 05:14:52 -0000 1.87
--- test_both.py 15 Dec 2002 16:35:55 -0000 1.88
***************
*** 2039,2042 ****
--- 2039,2063 ----
self.assertRaises(ValueError, cls(1,1,1, tzinfo=DST(-1440)).timetuple)
+ def test_tzinfo_isoformat(self):
+ zero = FixedOffset(0, "+00:00")
+ plus = FixedOffset(220, "+03:40")
+ minus = FixedOffset(-231, "-03:51")
+ unknown = FixedOffset(None, "")
+
+ cls = self.theclass
+ datestr = '0001-02-03'
+ for ofs in None, zero, plus, minus, unknown:
+ for us in 0, 987001:
+ d = cls(1, 2, 3, 4, 5, 59, us, tzinfo=ofs)
+ timestr = '04:05:59' + (us and '.987001' or '')
+ ofsstr = ofs is not None and d.tzname() or ''
+ tailstr = timestr + ofsstr
+ iso = d.isoformat()
+ self.assertEqual(iso, datestr + 'T' + tailstr)
+ self.assertEqual(iso, d.isoformat('T'))
+ self.assertEqual(d.isoformat('k'), datestr + 'k' + tailstr)
+ self.assertEqual(str(d), datestr + ' ' + tailstr)
+
+
def test_suite():
allsuites = [unittest.makeSuite(klass, 'test')
- Previous message: [Python-checkins] python/dist/src/Python modsupport.c,2.62,2.63
- Next message: [Python-checkins] python/nondist/sandbox/datetime datetime.c,1.74,1.75 datetime.py,1.107,1.108 doc.txt,1.54,1.55 obj_datetimetz.c,1.24,1.25 test_both.py,1.88,1.89
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]