Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support date instance for temporal oprators #75

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pygeofilter/parsers/cql2_json/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def walk_cql_json(node: JsonType): # noqa: C901
float,
int,
bool,
date,
datetime,
values.Geometry,
values.Interval,
Expand Down
16 changes: 15 additions & 1 deletion tests/parsers/cql2_json/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# ------------------------------------------------------------------------------

import json
from datetime import datetime, timedelta
from datetime import date, datetime, timedelta

from dateparser.timezone_parser import StaticTzInfo
from pygeoif import geometry
Expand Down Expand Up @@ -164,6 +164,20 @@ def test_attribute_before():
datetime(2000, 1, 1, 0, 0, 1, tzinfo=StaticTzInfo("Z", timedelta(0))),
)

result = parse(
{
"op": "t_before",
"args": [
{"property": "attr"},
{"date": "2000-01-01"},
],
}
)
assert result == ast.TimeBefore(
ast.Attribute("attr"),
date(2000, 1, 1),
)


def test_attribute_after_dt_dt():
result = parse(
Expand Down