Skip to content

Commit b32386e

Browse files
committed
Correct intervals handling
1 parent f6f313d commit b32386e

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

terminusdb_client/woqlquery/woql_query.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2438,6 +2438,36 @@ def interval_relation(self, relation, x_start, x_end, y_start, y_end):
24382438
self._cursor["y_end"] = self._clean_object(y_end)
24392439
return self
24402440

2441+
def interval(self, start, end, interval_val):
2442+
"""Constructs or deconstructs a half-open xdd:dateTimeInterval [start, end).
2443+
2444+
Bidirectional: given start+end computes interval, given interval
2445+
extracts start+end.
2446+
2447+
Parameters
2448+
----------
2449+
start : str or dict
2450+
inclusive start date
2451+
end : str or dict
2452+
exclusive end date
2453+
interval_val : str or dict
2454+
the xdd:dateTimeInterval value
2455+
2456+
Returns
2457+
-------
2458+
WOQLQuery object
2459+
query object that can be chained and/or execute
2460+
"""
2461+
if start is None or end is None or interval_val is None:
2462+
raise ValueError("Interval takes three parameters")
2463+
if self._cursor.get("@type"):
2464+
self._wrap_cursor_with_and()
2465+
self._cursor["@type"] = "Interval"
2466+
self._cursor["start"] = self._clean_object(start)
2467+
self._cursor["end"] = self._clean_object(end)
2468+
self._cursor["interval"] = self._clean_object(interval_val)
2469+
return self
2470+
24412471
def day_after(self, date, next_date):
24422472
"""Computes the calendar day after the given date. Bidirectional.
24432473

0 commit comments

Comments
 (0)