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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Fixed

- Fix incorrect min/max date formatting in `apply_datetime_filter` for `POST` requests. [#539](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/539)
- Fixed datetime filtering for .0Z milliseconds to preserve precision in apply_filter_datetime, ensuring only items exactly within the specified range are returned. [#535](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/535)
- Normalize datetime in POST /search requests to match GET /search behavior. [#543](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/543)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ def return_date(
if "/" in interval:
parts = interval.split("/")
result["gte"] = (
parts[0] if parts[0] != ".." else MIN_DATE_NANOS.isoformat() + "Z"
parts[0] if parts[0] != ".." else MIN_DATE_NANOS.isoformat()
)
result["lte"] = (
parts[1]
if len(parts) > 1 and parts[1] != ".."
else MAX_DATE_NANOS.isoformat() + "Z"
else MAX_DATE_NANOS.isoformat()
)
else:
converted_time = interval if interval != ".." else None
Expand All @@ -75,7 +75,7 @@ def return_date(
dt_utc = MIN_DATE_NANOS
elif dt_utc > MAX_DATE_NANOS:
dt_utc = MAX_DATE_NANOS
datetime_iso = dt_utc.isoformat()
datetime_iso = dt_utc.isoformat().replace("+00:00", "Z")
result["gte"] = result["lte"] = datetime_iso
elif isinstance(interval, tuple):
start, end = interval
Expand All @@ -90,7 +90,7 @@ def return_date(
start_utc = MIN_DATE_NANOS
elif start_utc > MAX_DATE_NANOS:
start_utc = MAX_DATE_NANOS
result["gte"] = start_utc.strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + "Z"
result["gte"] = start_utc.isoformat().replace("+00:00", "Z")
if end:
end_utc = (
end.astimezone(timezone.utc)
Expand All @@ -101,7 +101,7 @@ def return_date(
end_utc = MIN_DATE_NANOS
elif end_utc > MAX_DATE_NANOS:
end_utc = MAX_DATE_NANOS
result["lte"] = end_utc.strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + "Z"
result["lte"] = end_utc.isoformat().replace("+00:00", "Z")

return result

Expand Down Expand Up @@ -131,9 +131,9 @@ def return_date(
start, end = interval
# Ensure datetimes are converted to UTC and formatted with 'Z'
if start:
result["gte"] = start.strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + "Z"
result["gte"] = start.isoformat().replace("+00:00", "Z")
if end:
result["lte"] = end.strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + "Z"
result["lte"] = end.isoformat().replace("+00:00", "Z")

return result

Expand Down