Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyiceberg/utils/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def nanos_to_time(nanos: int) -> time:

def nanos_to_hours(nanos: int) -> int:
"""Convert a timestamp in nanoseconds to hours from 1970-01-01T00:00."""
return nanos // 3_600_000_000_0000
return nanos // 3_600_000_000_000


def nanos_to_micros(nanos: int) -> int:
Expand Down
12 changes: 12 additions & 0 deletions tests/utils/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
datetime_to_millis,
datetime_to_nanos,
millis_to_datetime,
nanos_to_hours,
nanos_to_micros,
time_str_to_nanos,
time_to_nanos,
Expand Down Expand Up @@ -132,3 +133,14 @@ def test_timestamptz_to_nanos(timestamp: str, nanos: int) -> None:
@pytest.mark.parametrize("nanos, micros", [(1510871468000001001, 1510871468000001), (-1510871468000001001, -1510871468000002)])
def test_nanos_to_micros(nanos: int, micros: int) -> None:
assert micros == nanos_to_micros(nanos)


@pytest.mark.parametrize(
"nanos, hours",
[
(1510871468000001001, 419686),
(-1510871468000001001, -419687),
],
)
def test_nanos_to_hours(nanos: int, hours: int) -> None:
assert hours == nanos_to_hours(nanos)