Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for non-ellipsis open date windows #103

Merged
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.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Unreleased
------------------
- Allow for non-ellipsis open temporal windows (#103, @moradology)

2.0.1 (2021-07-08)
------------------
Expand Down
8 changes: 4 additions & 4 deletions stac_pydantic/api/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def start_date(self) -> Optional[datetime]:
values = self.datetime.split("/")
if len(values) == 1:
return None
if values[0] == "..":
if values[0] == ".." or values[0] == "":
return None
return parse_datetime(values[0])

Expand All @@ -59,7 +59,7 @@ def end_date(self) -> Optional[datetime]:
values = self.datetime.split("/")
if len(values) == 1:
return parse_datetime(values[0])
if values[1] == "..":
if values[1] == ".." or values[1] == "":
return None
return parse_datetime(values[1])

Expand Down Expand Up @@ -108,8 +108,8 @@ def validate_datetime(cls, v):

dates = []
for value in values:
if value == "..":
dates.append(value)
if value == ".." or value == "":
dates.append("..")
continue

parse_datetime(value)
Expand Down
4 changes: 4 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ def test_temporal_search_two_tailed():
assert search.start_date == utcnow
assert search.end_date == None

search = Search(collections=["collection1"], datetime=f"{utcnow_str}/")
assert search.start_date == utcnow
assert search.end_date == None


def test_temporal_search_open():
# Test open date range
Expand Down