Skip to content

How to tell if search is for single datetime? (Should str_to_interval return a single value for that?) #688

Closed
@avbentem

Description

@avbentem

I'd guess this is a bug, but maybe not, so a question first:

The STAC API - Item Search specs define:

datetime

Single date+time, or a range ('/' separator), formatted to RFC 3339, section 5.6. Use double dots .. for open date ranges.

If only a single date+time is provided, I'd guess this implies one searches for an exact match?

Indeed, DateTimeType allows for a single value too:

DateTimeType = Union[
    datetime,
    Tuple[datetime, datetime],
    Tuple[datetime, None],
    Tuple[None, datetime],
]

All good so far. However, today's str_to_interval always returns a tuple. And that function is used as the converter for the search request:

class BaseSearchGetRequest(APIRequest):
    ...
    datetime: Optional[DateTimeType] = attr.ib(default=None, converter=str_to_interval)
   ...

So when implementing get_search how would one know if a single date+time was requested, or a range with an open end?

The tests only check intervals, so are not giving me the definitive answer. But I'm guessing this is an oversight?

(Of course I can provide a PR if this is indeed a bug.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions