diff --git a/pyswagger/primitives.py b/pyswagger/primitives.py index dbdbd7b..63b3c29 100644 --- a/pyswagger/primitives.py +++ b/pyswagger/primitives.py @@ -79,7 +79,7 @@ def __init__(self, _, v): """ self.v = None if isinstance(v, float): - self.v = datetime.datetime.fromtimestamp(v) + self.v = datetime.datetime.utcfromtimestamp(v) elif isinstance(v, datetime.datetime): self.v = v elif isinstance(v, six.string_types): diff --git a/pyswagger/tests/v2_0/test_prim.py b/pyswagger/tests/v2_0/test_prim.py index 9481ea9..e0a3ec3 100644 --- a/pyswagger/tests/v2_0/test_prim.py +++ b/pyswagger/tests/v2_0/test_prim.py @@ -139,13 +139,13 @@ def test_date_time(self): d = self.app.resolve("#/definitions/date-time") # test input of constructor - self.assertEqual(str(d._prim_(float(0))), "1970-01-01T08:00:00") - self.assertEqual(str(d._prim_(datetime.datetime.fromtimestamp(0))), "1970-01-01T08:00:00") - self.assertEqual(str(d._prim_(datetime.datetime.fromtimestamp(0).isoformat())), "1970-01-01T08:00:00") + self.assertEqual(str(d._prim_(float(0))), "1970-01-01T00:00:00") + self.assertEqual(str(d._prim_(datetime.datetime.utcfromtimestamp(0))), "1970-01-01T00:00:00") + self.assertEqual(str(d._prim_(datetime.datetime.utcfromtimestamp(0).isoformat())), "1970-01-01T00:00:00") # to_json dv = d._prim_(float(0)) - self.assertEqual(dv.to_json(), "1970-01-01T08:00:00") + self.assertEqual(dv.to_json(), "1970-01-01T00:00:00") class HeaderTestCase(unittest.TestCase):