rdblue commented on code in PR #5667:
URL: https://github.com/apache/iceberg/pull/5667#discussion_r957709337
##########
python/pyiceberg/utils/datetime.py:
##########
@@ -133,28 +133,24 @@ def to_human_timestamp(timestamp_micros: int) -> str:
return (EPOCH_TIMESTAMP +
timedelta(microseconds=timestamp_micros)).isoformat()
-def micros_to_hours(timestamp: int) -> int:
- """Converts a timestamp in microseconds to a date in hours"""
- return int((datetime.utcfromtimestamp(timestamp // 1_000_000) -
EPOCH_TIMESTAMP).total_seconds() / 3600)
+def micros_to_hours(micros: int) -> int:
+ """Converts a timestamp in microseconds to hours from 1970-01-01T00:00"""
+ return micros // 3_600_000_000
Review Comment:
This converts to a timestamp only to get back to a delta, and then get the
seconds. Instead, we can convert directly.
--
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]