From d0d6f1ddac27408996ad5de12978b78b760655ae Mon Sep 17 00:00:00 2001 From: kaveh Date: Mon, 17 Apr 2023 10:57:18 +0200 Subject: [PATCH] Support date instance for temporal oprators --- pygeofilter/parsers/cql2_json/parser.py | 1 + tests/parsers/cql2_json/test_parser.py | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pygeofilter/parsers/cql2_json/parser.py b/pygeofilter/parsers/cql2_json/parser.py index 74b41da..62af434 100644 --- a/pygeofilter/parsers/cql2_json/parser.py +++ b/pygeofilter/parsers/cql2_json/parser.py @@ -48,6 +48,7 @@ def walk_cql_json(node: JsonType): # noqa: C901 float, int, bool, + date, datetime, values.Geometry, values.Interval, diff --git a/tests/parsers/cql2_json/test_parser.py b/tests/parsers/cql2_json/test_parser.py index b78d440..34fb027 100644 --- a/tests/parsers/cql2_json/test_parser.py +++ b/tests/parsers/cql2_json/test_parser.py @@ -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 @@ -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(