Commit 9d464701 by Don Mitchell

timezone conversion tests

parent 4c8a92e9
......@@ -4,6 +4,7 @@ import unittest
from django.utils.timezone import UTC
from xmodule.fields import Date, Timedelta
from xmodule.timeinfo import TimeInfo
import time
class DateTest(unittest.TestCase):
......@@ -55,6 +56,14 @@ class DateTest(unittest.TestCase):
DateTest.date.from_json("December 4 16:30"))
self.assertIsNone(DateTest.date.from_json("12 12:00"))
def test_odd_from_json(self):
now = datetime.datetime.now(UTC())
delta = now - datetime.datetime.fromtimestamp(0, UTC())
self.assertEqual(DateTest.date.from_json(delta.total_seconds() * 1000),
now)
yesterday = datetime.datetime.now(UTC()) - datetime.timedelta(days=-1)
self.assertEqual(DateTest.date.from_json(yesterday), yesterday)
def test_to_json(self):
'''
Test converting time reprs to iso dates
......
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