Commit d98ce9ff authored by Nicolas Delaby's avatar Nicolas Delaby

Use Explicit timezone GMT+7

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19156 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4450bd7d
...@@ -55,71 +55,74 @@ from DateTime import DateTime ...@@ -55,71 +55,74 @@ from DateTime import DateTime
from Products.ERP5Type.DateUtils import addToDate from Products.ERP5Type.DateUtils import addToDate
class TestDateUtils(unittest.TestCase): class TestDateUtils(unittest.TestCase):
"""Tests field value caching system
""" """
Tests DateUtils
"""
timezone = 'GMT+7'
def getTitle(self): def getTitle(self):
return "Date Utils" return "Date Utils"
def test_integer_add_to_date(self): def test_integer_add_to_date(self):
date = DateTime('2000/01/01 UTC') date = DateTime('2000/01/01 %s' % self.timezone)
self.assertEqual(DateTime('2000/01/01 00:01:30 UTC').ISO(), self.assertEqual(DateTime('2000/01/01 00:01:30 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(date, second=90).ISO()) addToDate(date, second=90).toZone('UTC').ISO())
self.assertEqual(DateTime('2000/01/01 01:30:00 UTC').ISO(), self.assertEqual(DateTime('2000/01/01 01:30:00 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(date, minute=90).ISO()) addToDate(date, minute=90).toZone('UTC').ISO())
self.assertEqual(DateTime('2000/01/04 18:00:00 UTC').ISO(), self.assertEqual(DateTime('2000/01/04 18:00:00 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(date, hour=90).ISO()) addToDate(date, hour=90).toZone('UTC').ISO())
self.assertEqual(DateTime('2000/03/31 UTC').ISO(), self.assertEqual(DateTime('2000/03/31 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(date, day=90).ISO()) addToDate(date, day=90).toZone('UTC').ISO())
self.assertEqual(DateTime('2007/07/01 UTC').ISO(), self.assertEqual(DateTime('2007/07/01 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(date, month=90).ISO()) addToDate(date, month=90).toZone('UTC').ISO())
self.assertEqual(DateTime('2090/01/01 UTC').ISO(), self.assertEqual(DateTime('2090/01/01 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(date, year=90).ISO()) addToDate(date, year=90).toZone('UTC').ISO())
def test_negative_add_to_date(self): def test_negative_add_to_date(self):
date = DateTime('2000/01/01 UTC') date = DateTime('2000/01/01 %s' % self.timezone)
self.assertEqual(DateTime('1999/12/31 23:59:59 UTC').ISO(), self.assertEqual(DateTime('1999/12/31 23:59:59 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(date, second=-1).ISO()) addToDate(date, second=-1).toZone('UTC').ISO())
self.assertEqual(DateTime('1999/12/31 23:59:00 UTC').ISO(), self.assertEqual(DateTime('1999/12/31 23:59:00 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(date, minute=-1).ISO()) addToDate(date, minute=-1).toZone('UTC').ISO())
self.assertEqual(DateTime('1999/12/31 23:00:00 UTC').ISO(), self.assertEqual(DateTime('1999/12/31 23:00:00 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(date, hour=-1).ISO()) addToDate(date, hour=-1).toZone('UTC').ISO())
self.assertEqual(DateTime('1999/12/31 00:00:00 UTC').ISO(), self.assertEqual(DateTime('1999/12/31 00:00:00 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(date, day=-1).ISO()) addToDate(date, day=-1).toZone('UTC').ISO())
self.assertEqual(DateTime('1999/12/01 00:00:00 UTC').ISO(), self.assertEqual(DateTime('1999/12/01 00:00:00 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(date, month=-1).ISO()) addToDate(date, month=-1).toZone('UTC').ISO())
self.assertEqual(DateTime('1999/01/01').ISO(), self.assertEqual(DateTime('1999/01/01 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(date, year=-1).ISO()) addToDate(date, year=-1).toZone('UTC').ISO())
def test_float_add_to_date(self): def test_float_add_to_date(self):
date = DateTime('2000/01/01 UTC') date = DateTime('2000/01/01 %s' % self.timezone)
self.assertEqual(DateTime('2000/01/01').ISO(), self.assertEqual(DateTime('2000/01/01 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(date, second=0.5).ISO()) addToDate(date, second=0.5).toZone('UTC').ISO())
self.assertEqual(DateTime('2000/01/01 00:00:30 UTC').ISO(), self.assertEqual(DateTime('2000/01/01 00:00:30 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(date, minute=0.5).ISO()) addToDate(date, minute=0.5).toZone('UTC').ISO())
self.assertEqual(DateTime('2000/01/01 00:30:00 UTC').ISO(), self.assertEqual(DateTime('2000/01/01 00:30:00 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(date, hour=0.5).ISO()) addToDate(date, hour=0.5).toZone('UTC').ISO())
self.assertEqual(DateTime('2000/01/01 12:00:00 UTC').ISO(), self.assertEqual(DateTime('2000/01/01 12:00:00 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(date, day=0.5).ISO()) addToDate(date, day=0.5).toZone('UTC').ISO())
self.assertEqual(DateTime('2000/01/16 12:00:00 UTC').ISO(), self.assertEqual(DateTime('2000/01/16 12:00:00 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(date, month=0.5).ISO()) addToDate(date, month=0.5).toZone('UTC').ISO())
self.assertEqual(DateTime('2000/07/01').ISO(), self.assertEqual(DateTime('2000/07/01 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(date, year=0.5).ISO()) addToDate(date, year=0.5).toZone('UTC').ISO())
def test_complex_float_add_to_date(self): def test_complex_float_add_to_date(self):
complex_date = DateTime('2004/03/16 01:23:54 UTC') complex_date = DateTime('2004/03/16 01:23:54 %s' % self.timezone)
self.assertEqual(DateTime('2004/03/16 01:23:54 UTC').ISO(), self.assertEqual(DateTime('2004/03/16 01:23:54 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(complex_date, second=0.5).ISO()) addToDate(complex_date, second=0.5).toZone('UTC').ISO())
self.assertEqual(DateTime('2004/03/16 01:24:24 UTC').ISO(), self.assertEqual(DateTime('2004/03/16 01:24:24 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(complex_date, minute=0.5).ISO()) addToDate(complex_date, minute=0.5).toZone('UTC').ISO())
self.assertEqual(DateTime('2004/03/16 01:53:54 UTC').ISO(), self.assertEqual(DateTime('2004/03/16 01:53:54 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(complex_date, hour=0.5).ISO()) addToDate(complex_date, hour=0.5).toZone('UTC').ISO())
self.assertEqual(DateTime('2004/03/16 13:23:54 UTC').ISO(), self.assertEqual(DateTime('2004/03/16 13:23:54 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(complex_date, day=0.5).ISO()) addToDate(complex_date, day=0.5).toZone('UTC').ISO())
self.assertEqual(DateTime('2004/03/31 13:23:54 UTC').ISO(), self.assertEqual(DateTime('2004/03/31 13:23:54 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(complex_date, month=0.5).ISO()) addToDate(complex_date, month=0.5).toZone('UTC').ISO())
self.assertEqual(DateTime('2004/09/16 01:23:54 UTC').ISO(), self.assertEqual(DateTime('2004/09/16 01:23:54 %s' % self.timezone).toZone('UTC').ISO(),
addToDate(complex_date, year=0.5).ISO()) addToDate(complex_date, year=0.5).toZone('UTC').ISO())
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment