-
Notifications
You must be signed in to change notification settings - Fork 29
Closed
Labels
Description
The datetime attribute of a search request is defined to be an exact datetime, or a range with possible open ends on either side:
Parameter Type Source API Description ... datetime string OAFeat Single date+time, or a range ('/' separator), formatted to RFC 3339, section 5.6. Use double dots ..for open date ranges....
But today, the start_date and end_date properties are implemented as:
stac-pydantic/stac_pydantic/api/search.py
Lines 46 to 62 in 79248a2
| @property | |
| def start_date(self) -> Optional[dt]: | |
| values = (self.datetime or "").split("/") | |
| if len(values) == 1: | |
| return None | |
| if values[0] == ".." or values[0] == "": | |
| return None | |
| return parse_rfc3339(values[0]) | |
| @property | |
| def end_date(self) -> Optional[dt]: | |
| values = (self.datetime or "").split("/") | |
| if len(values) == 1: | |
| return parse_rfc3339(values[0]) | |
| if values[1] == ".." or values[1] == "": | |
| return None | |
| return parse_rfc3339(values[1]) |
This implies that for a single value, start_date is left empty and only end_date is set:
| datetime | start_date | end_date |
|---|---|---|
2012-07-02T00:00:00Z |
None | 2012-07-02 00:00 |
2012-07-02T00:00:00Z/.. |
2012-07-02 00:00 | None |
../2012-07-03T23:59:59Z |
None | 2012-07-03 00:00 |
I very much assume for a single datetime (the first case above) both start_date and end_date should be set to the same value?
(I can submit a PR if this is indeed a bug. It's just line 50 that should be changed from return None into return parse_rfc3339(values[0]). EDIT: also def validate_datetime would need a fix; see below.)
jonhealy1 and vincentsarago