You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by dk...@apache.org on 2017/12/15 21:32:35 UTC

[28/39] tinkerpop git commit: TINKERPOP-1848 use a generated datetime so that comparison can ignore timezone/dst differences

TINKERPOP-1848 use a generated datetime so that comparison can ignore timezone/dst differences


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/7f3ecf26
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/7f3ecf26
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/7f3ecf26

Branch: refs/heads/TINKERPOP-1447
Commit: 7f3ecf2662a5add9f24fbea37314b2412150319c
Parents: f015341
Author: Robert Dale <ro...@gmail.com>
Authored: Mon Dec 4 11:50:09 2017 -0500
Committer: Robert Dale <ro...@gmail.com>
Committed: Mon Dec 4 11:50:09 2017 -0500

----------------------------------------------------------------------
 .../main/jython/gremlin_python/structure/io/graphson.py   |  3 +--
 .../src/main/jython/tests/structure/io/test_graphson.py   | 10 ++++++++--
 2 files changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7f3ecf26/gremlin-python/src/main/jython/gremlin_python/structure/io/graphson.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphson.py b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphson.py
index 04085ee..24e86bb 100644
--- a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphson.py
+++ b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphson.py
@@ -328,8 +328,7 @@ class DateIO(_GraphSONTypeIO):
             pts = obj.timestamp()
         else:
             # Hack for legacy Python
-            # Taken from:
-            # https://github.com/jaraco/backports.datetime_timestamp/blob/master/backports/datetime_timestamp/__init__.py
+            # timestamp() in Python 3.3
             pts = time.mktime((obj.year, obj.month, obj.day,
 			                   obj.hour, obj.minute, obj.second,
 			                   -1, -1, -1)) + obj.microsecond / 1e6

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7f3ecf26/gremlin-python/src/main/jython/tests/structure/io/test_graphson.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/structure/io/test_graphson.py b/gremlin-python/src/main/jython/tests/structure/io/test_graphson.py
index 633dcf7..928b33f 100644
--- a/gremlin-python/src/main/jython/tests/structure/io/test_graphson.py
+++ b/gremlin-python/src/main/jython/tests/structure/io/test_graphson.py
@@ -19,6 +19,7 @@ under the License.
 
 __author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
 import datetime
+import time
 import json
 import uuid
 
@@ -126,10 +127,15 @@ class TestGraphSONReader(object):
         assert o is serdes.objectify()
 
     def test_datetime(self):
-        dt = self.graphson_reader.readObject(json.dumps({"@type": "g:Date", "@value": 1481750076295}))
+        expected = datetime.datetime(2016, 12, 14, 16, 14, 36, 295000)
+        pts = time.mktime((expected.year, expected.month, expected.day,
+                                           expected.hour, expected.minute, expected.second,
+                                           -1, -1, -1)) + expected.microsecond / 1e6
+        timestamp = int(round(pts * 1000))
+        dt = self.graphson_reader.readObject(json.dumps({"@type": "g:Date", "@value": timestamp}))
         assert isinstance(dt, datetime.datetime)
         # TINKERPOP-1848
-        # assert dt == datetime.datetime(2016, 12, 14, 16, 14, 36, 295000, tzinfo=None)
+        assert dt == expected
 
     def test_timestamp(self):
         dt = self.graphson_reader.readObject(json.dumps({"@type": "g:Timestamp", "@value": 1481750076295}))