-
Couldn't load subscription status.
- Fork 56
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
When you pass a str date to search without leading zeros on the months (e.g '2020-7/2020-8'), the current DATETIME_REGEX only matches the years and ignores the months, since the months are incorrectly formatted. This causes the final datetime to consist only of the years (e.g 2020-2020).
>>> api = Client.open("https://planetarycomputer.microsoft.com/api/stac/v1")
>>> bad_date_str = '2020-7/2020-8'
>>> aoi = box(35.434076765062386, 7.548766587474588, 35.57903679114287, 7.799796217489619)
>>> search = api.search(collections=['sentinel-2-l2a'], intersects=aoi, datetime=bad_date_str)
>>> items = search.get_all_items()
>>> len(items)
143
>>> good_date_str = '2020-07/2020-08'
>>> search = api.search(collections=['sentinel-2-l2a'], intersects=aoi, datetime=bad_date_str)
>>> items = search.get_all_items()
>>> len(items)
24
I would expect that this sort of poorly formatted string would raise an error instead of ignoring the portion of the string unmatched by the regex expression (in our case, the months with no leading zero).
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working