Fokko commented on code in PR #8026:
URL: https://github.com/apache/iceberg/pull/8026#discussion_r1257784684
##########
python/pyiceberg/utils/datetime.py:
##########
@@ -91,6 +91,25 @@ def timestamp_to_micros(timestamp_str: str) -> int:
raise ValueError(f"Invalid timestamp without zone: {timestamp_str} (must
be ISO-8601)")
+def datetime_to_millis(dt: datetime) -> int:
+ """Converts a datetime to milliseconds from 1970-01-01T00:00:00.000000."""
+ if dt.tzinfo:
+ delta = dt - EPOCH_TIMESTAMPTZ
+ else:
+ delta = dt - EPOCH_TIMESTAMP
+ return (delta.days * 86400 + delta.seconds) * 1_000 + delta.microseconds
// 1_000
+
+
+def timestamp_to_millis(timestamp_str: str) -> int:
Review Comment:
Why add this one when we don't use it? I would rather leave it out.
##########
python/pyiceberg/utils/datetime.py:
##########
@@ -91,6 +91,25 @@ def timestamp_to_micros(timestamp_str: str) -> int:
raise ValueError(f"Invalid timestamp without zone: {timestamp_str} (must
be ISO-8601)")
+def datetime_to_millis(dt: datetime) -> int:
Review Comment:
Could you add an unit test for this one?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]