File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
sfeos_helpers/stac_fastapi/sfeos_helpers/database Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 11"""Utility functions to handle datetime parsing."""
22
3+ import math
34from datetime import datetime , timezone
45
56from stac_fastapi .types .rfc3339 import rfc3339_str_to_datetime
@@ -23,7 +24,9 @@ def normalize(dt):
2324 return ".."
2425 dt_obj = rfc3339_str_to_datetime (dt )
2526 dt_utc = dt_obj .astimezone (timezone .utc )
26- rounded_dt = dt_utc .replace (microsecond = round (dt_utc .microsecond / 1000 ) * 1000 )
27+ rounded_dt = dt_utc .replace (
28+ microsecond = math .floor (dt_utc .microsecond / 1000 + 0.5 ) * 1000
29+ )
2730 return rounded_dt .isoformat (timespec = "milliseconds" ).replace ("+00:00" , "Z" )
2831
2932 if not isinstance (date_str , str ):
Original file line number Diff line number Diff line change 55"""
66
77import logging
8+ import math
89import re
910from datetime import date
1011from datetime import datetime as datetime_type
@@ -44,7 +45,9 @@ def normalize_datetime(dt_str):
4445 return dt_str
4546 dt_obj = rfc3339_str_to_datetime (dt_str )
4647 dt_utc = dt_obj .astimezone (timezone .utc )
47- rounded_dt = dt_utc .replace (microsecond = round (dt_utc .microsecond / 1000 ) * 1000 )
48+ rounded_dt = dt_utc .replace (
49+ microsecond = math .floor (dt_utc .microsecond / 1000 + 0.5 ) * 1000
50+ )
4851 return rounded_dt .isoformat (timespec = "milliseconds" ).replace ("+00:00" , "Z" )
4952
5053 result : Dict [str , Optional [str ]] = {"gte" : None , "lte" : None }
You can’t perform that action at this time.
0 commit comments