Cole-Greer commented on code in PR #3090:
URL: https://github.com/apache/tinkerpop/pull/3090#discussion_r2029345427


##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/translator/PythonTranslateVisitor.java:
##########
@@ -161,8 +162,8 @@ public Void visitMapEntry(final 
GremlinParser.MapEntryContext ctx) {
     public Void visitDateLiteral(final GremlinParser.DateLiteralContext ctx) {
         // child at 2 is the date argument to datetime() and comes enclosed in 
quotes
         final String dtString = ctx.getChild(2).getText();
-        final Date dt = 
DatetimeHelper.parse(removeFirstAndLastCharacters(dtString));
-        sb.append("datetime.datetime.utcfromtimestamp(" + dt.getTime() + " / 
1000.0)");
+        final OffsetDateTime dt = 
DatetimeHelper.parse(removeFirstAndLastCharacters(dtString));
+        sb.append("datetime.datetime.fromtimestamp(" + dt.toEpochSecond() + 
").astimezone(datetime.timezone.utc)");

Review Comment:
   Are we unnecessarily losing precision by using `dt.toEpochSecond()`? 
Python's datetime.datetime supports microsecond precision: 
https://docs.python.org/3/library/datetime.html#datetime.datetime. Perhaps 
[fromisoformat](https://docs.python.org/3/library/datetime.html#datetime.datetime.fromisoformat)
 is preferable.
   
   Same comment applies for the old PythonTranslator.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to