Skip to content

Commit

Permalink
Revert "jsonutils: replace strtime() usage with isoformat()"
Browse files Browse the repository at this point in the history
This is a wire format change that the projects are not ready for yet (example Nova).

We should do this as part of a major version bump (2.x) with ample time for folks to move up.

Nova review to prepare the Nova code base for this change:
Ib7e60ed94edd1eb409baf8c29c61237d85944787

This reverts commit 5b0827a.

Change-Id: Ic4bf047b40c1dad2f8d2bc0afda934e47dba1f9d
  • Loading branch information
dims committed Jun 1, 2015
1 parent 986ec58 commit 15c82cc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
3 changes: 2 additions & 1 deletion oslo_serialization/jsonutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@

from oslo_utils import encodeutils
from oslo_utils import importutils
from oslo_utils import timeutils
import six
import six.moves.xmlrpc_client as xmlrpclib

Expand Down Expand Up @@ -110,7 +111,7 @@ def to_primitive(value, convert_instances=False, convert_datetime=True,

if isinstance(value, datetime.datetime):
if convert_datetime:
return value.isoformat()
return timeutils.strtime(value)
else:
return value

Expand Down
9 changes: 1 addition & 8 deletions oslo_serialization/tests/test_jsonutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import datetime
import json

import iso8601
import mock
import netaddr
from oslo_i18n import fixture
Expand Down Expand Up @@ -136,12 +135,6 @@ def test_datetime(self):
self.assertEqual(jsonutils.to_primitive(x),
'1920-02-03T04:05:06.000007')

def test_datetime_timezone(self):
x = datetime.datetime(1920, 2, 3, 4, 5, 6, 7,
tzinfo=iso8601.iso8601.UTC)
self.assertEqual(jsonutils.to_primitive(x),
'1920-02-03T04:05:06.000007+00:00')

def test_datetime_preserve(self):
x = datetime.datetime(1920, 2, 3, 4, 5, 6, 7)
self.assertEqual(jsonutils.to_primitive(x, convert_datetime=False), x)
Expand All @@ -150,7 +143,7 @@ def test_DateTime(self):
x = xmlrpclib.DateTime()
x.decode("19710203T04:05:06")
self.assertEqual(jsonutils.to_primitive(x),
'1971-02-03T04:05:06')
'1971-02-03T04:05:06.000000')

def test_iter(self):
class IterClass(object):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_jsonutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def test_DateTime(self):
x = xmlrpclib.DateTime()
x.decode("19710203T04:05:06")
self.assertEqual(jsonutils.to_primitive(x),
'1971-02-03T04:05:06')
'1971-02-03T04:05:06.000000')

def test_iter(self):
class IterClass(object):
Expand Down

0 comments on commit 15c82cc

Please sign in to comment.