Skip to content

Search start_date property does not support single-value for datetime #145

@avbentem

Description

@avbentem

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:

@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.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions