Skip to content

Commit

Permalink
Merge pull request #103 from moradology/feature/non-ellipsis-open-dat…
Browse files Browse the repository at this point in the history
…e-windows

Add support for non-ellipsis open date windows
  • Loading branch information
moradology authored Nov 22, 2021
2 parents ebd64aa + 2f7d1d5 commit 4ad4577
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
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

0 comments on commit 4ad4577

Please sign in to comment.