Skip to content

Commit f5a372d

Browse files
committed
set start/end datetime to the unique datetime passed in api.Search
1 parent b18cc74 commit f5a372d

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

Diff for: CHANGELOG.txt

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- use `StacBaseModel` as base model for `Asset` model (#148, @vincentsarago)
1414
- add `license` in `StacCommonMetadata` model (#147, @vincentsarago)
1515
- make `limit` optional in `api.Search` model (#150, @vincentsarago)
16+
- set `start/end datetime` to the datetime value when passing only one value in `api.Search`
1617

1718
3.0.0 (2024-01-25)
1819
------------------

Diff for: stac_pydantic/api/search.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ def validate_datetime(cls, value: str) -> str:
108108
"Invalid datetime range. Too many values. Must match format: {begin_date}/{end_date}"
109109
)
110110

111-
# If there is only one date, insert a None for the start date
111+
# If there is only one date, duplicate to use for both start and end dates
112112
if len(values) == 1:
113-
values.insert(0, None)
113+
values = [values[0], values[0]]
114114

115115
# Cast because pylance gets confused by the type adapter and annotated type
116116
dates = cast(

Diff for: tests/api/test_search.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_temporal_search_single_tailed():
5858
utcnow = datetime.now(timezone.utc)
5959
utcnow_str = utcnow.isoformat()
6060
search = Search(collections=["collection1"], datetime=utcnow_str)
61-
assert search.start_date is None
61+
assert search.start_date == utcnow
6262
assert search.end_date == utcnow
6363

6464

0 commit comments

Comments
 (0)