Skip to content

Commit 80b20a6

Browse files
author
Richard Jones
committed
fixed bug in Interval serialisation
1 parent 81631f3 commit 80b20a6

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

roundup/date.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: date.py,v 1.32 2002-09-23 12:09:29 richard Exp $
18+
# $Id: date.py,v 1.33 2002-10-10 07:18:02 richard Exp $
1919

2020
__doc__ = """
2121
Date, time and time interval handling.
@@ -446,7 +446,8 @@ def get_tuple(self):
446446
self.minute, self.second)
447447

448448
def serialise(self):
449-
return '%s%4d%02d%02d%02d%02d%02d'%(self.sign, self.year, self.month,
449+
sign = self.sign > 0 and '+' or '-'
450+
return '%s%04d%02d%02d%02d%02d%02d'%(sign, self.year, self.month,
450451
self.day, self.hour, self.minute, self.second)
451452

452453

test/test_db.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: test_db.py,v 1.59 2002-10-08 07:28:34 richard Exp $
18+
# $Id: test_db.py,v 1.60 2002-10-10 07:18:03 richard Exp $
1919

2020
import unittest, os, shutil, time
2121

@@ -135,12 +135,22 @@ def testDateChange(self):
135135
self.assertEqual(self.db.issue.get('1', "deadline"), None)
136136

137137
def testIntervalChange(self):
138-
self.db.issue.create(title="spam", status='1')
139-
a = self.db.issue.get('1', "foo")
140-
self.db.issue.set('1', foo=date.Interval('-1d'))
141-
self.assertNotEqual(self.db.issue.get('1', "foo"), a)
142-
self.db.issue.set('1', foo=None)
143-
self.assertEqual(self.db.issue.get('1', "foo"), None)
138+
nid = self.db.issue.create(title="spam", status='1')
139+
self.db.commit()
140+
a = self.db.issue.get(nid, "foo")
141+
i = date.Interval('-1d')
142+
self.db.issue.set(nid, foo=i)
143+
self.db.commit()
144+
self.assertNotEqual(self.db.issue.get(nid, "foo"), a)
145+
self.assertEqual(i, self.db.issue.get(nid, "foo"))
146+
j = date.Interval('1y')
147+
self.db.issue.set(nid, foo=j)
148+
self.db.commit()
149+
self.assertNotEqual(self.db.issue.get(nid, "foo"), i)
150+
self.assertEqual(j, self.db.issue.get(nid, "foo"))
151+
self.db.issue.set(nid, foo=None)
152+
self.db.commit()
153+
self.assertEqual(self.db.issue.get(nid, "foo"), None)
144154

145155
def testBooleanChange(self):
146156
userid = self.db.user.create(username='foo', assignable=1)

0 commit comments

Comments
 (0)