Skip to content

Commit c067d0f

Browse files
Yuri ZmytrakovYuri Zmytrakov
authored andcommitted
fix: round milliseconds instead of truncating
1 parent 0517b4b commit c067d0f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

stac_fastapi/core/stac_fastapi/core/datetime_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ def normalize(dt):
2323
return ".."
2424
dt_obj = rfc3339_str_to_datetime(dt)
2525
dt_utc = dt_obj.astimezone(timezone.utc)
26-
return dt_utc.isoformat(timespec="milliseconds").replace("+00:00", "Z")
26+
rounded_dt = dt_utc.replace(microsecond=round(dt_utc.microsecond / 1000) * 1000)
27+
return rounded_dt.isoformat(timespec="milliseconds").replace("+00:00", "Z")
2728

2829
if not isinstance(date_str, str):
2930
return "../.."

0 commit comments

Comments
 (0)