From: richard Date: Mon, 9 Dec 2002 02:43:21 +0000 (+0000) Subject: fix Date.local() X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2cde21add45ebe056ae4dc5f70e3caf1d9c68c5f;p=roundup.git fix Date.local() git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1392 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/roundup/date.py b/roundup/date.py index 54265d1..aee9acd 100644 --- a/roundup/date.py +++ b/roundup/date.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: date.py,v 1.36 2002-10-12 23:10:36 richard Exp $ +# $Id: date.py,v 1.37 2002-12-09 02:43:21 richard Exp $ __doc__ = """ Date, time and time interval handling. @@ -273,11 +273,10 @@ class Date: return ''%self.__str__() def local(self, offset): - """Return this date as yyyy-mm-dd.hh:mm:ss in a local time zone.""" - t = (self.year, self.month, self.day, self.hour + offset, self.minute, - self.second, 0, 0, 0) - self.year, self.month, self.day, self.hour, self.minute, \ - self.second, x, x, x = time.gmtime(calendar.timegm(t)) + """ Return this date as yyyy-mm-dd.hh:mm:ss in a local time zone. + """ + return Date((self.year, self.month, self.day, self.hour + offset, + self.minute, self.second, 0, 0, 0)) def get_tuple(self): return (self.year, self.month, self.day, self.hour, self.minute, diff --git a/test/test_dates.py b/test/test_dates.py index 88accdb..10cc10c 100644 --- a/test/test_dates.py +++ b/test/test_dates.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: test_dates.py,v 1.14 2002-10-11 01:25:40 richard Exp $ +# $Id: test_dates.py,v 1.15 2002-12-09 02:43:21 richard Exp $ import unittest, time @@ -138,6 +138,11 @@ class DateTestCase(unittest.TestCase): date = Date('2001-03-01.00:00:00') - Interval('00:00:3661') ae(str(date), '2001-02-28.22:58:59') + # local() + date = Date("02:42:20") + date = date.local(10) + ae(str(date), '%s-%02d-%02d.12:42:20'%(y, m, d)) + def testInterval(self): ae = self.assertEqual ae(str(Interval('3y')), '+ 3y')