Anurag-S1ngh commented on code in PR #4406:
URL: https://github.com/apache/iceberg-python/pull/4406#discussion_r4612825251


##########
pyiceberg/utils/datetime.py:
##########
@@ -229,22 +229,39 @@ def micros_to_hours(micros: int) -> int:
     return micros // 3_600_000_000
 
 
+def _civil_from_days(days: int) -> tuple[int, int]:
+    """Return the year and month of the number of days from 1970-01-01.
+
+    The conversion uses integer arithmetic, so values outside the range of 
``datetime.date``, such
+    as the day after 9999-12-31, are converted as well. Based on
+    https://howardhinnant.github.io/date_algorithms.html#civil_from_days.
+    """
+    z = days + 719468
+    era = (z if z >= 0 else z - 146096) // 146097

Review Comment:
   Fixed in c6e658d2: `era = z // 146097`. Added `(-719529, -1971, -23641)` to 
`test_days_to_years_and_months`, so the `z < 0` branch is pinned now.
   



-- 
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]

Reply via email to