Skip to content

Commit

Permalink
missing timezone in fromtimestamp
Browse files Browse the repository at this point in the history
restrict on utc
  • Loading branch information
mission-liao committed Nov 26, 2014
1 parent 0d603d9 commit af78117
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyswagger/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions pyswagger/tests/v2_0/test_prim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit af78117

Please sign in to comment.