Skip to content

Support date comparisons, e.g. less than, greater than #3480

Open
@patkujawa-wf

Description

@patkujawa-wf

Problem to solve

I've captured two dates and want to assert that one is earlier than the other, but I get a type error:

65 | jsonpath "$.results[0].created_at" toDate "%+" format "%a, %d %b %Y %H:%M:%S" toDate "%a, %d %b %Y %H:%M:%S" < {{ request_date }}
   |   actual:   date <2024-12-04 17:54:52 UTC>
   |   expected: less than date <2024-12-04 18:26:57 UTC>
   |   >>> types between actual and expected are not consistent

Proposal

Expand the comparison predicates (e.g. https://hurl.dev/docs/grammar.html#less-predicate) to allow dates as well as the current numbers and strings.

Relates somewhat to #798

Alternatives

I see that https://hurl.dev/docs/filters.html#daysbeforenow is one filter, but I need something on the order of seconds rather than days, so perhaps a secondsBeforeNow filter could be used for both dates (or in my case I can just hardcode a value of 5 seconds).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions