Skip to content

Commit 512f684

Browse files
committed
New type, xdd:dateTimeInterval for iso8601 interval support
1 parent b32386e commit 512f684

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

terminusdb_client/woqlquery/woql_query.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2468,6 +2468,66 @@ def interval(self, start, end, interval_val):
24682468
self._cursor["interval"] = self._clean_object(interval_val)
24692469
return self
24702470

2471+
def interval_start_duration(self, start, duration, interval_val):
2472+
"""Relates an xdd:dateTimeInterval to its start endpoint and precise xsd:duration.
2473+
2474+
Bidirectional: given interval extracts start+duration, given
2475+
start+duration computes interval.
2476+
2477+
Parameters
2478+
----------
2479+
start : str or dict
2480+
inclusive start date or dateTime
2481+
duration : str or dict
2482+
the xsd:duration between start and end
2483+
interval_val : str or dict
2484+
the xdd:dateTimeInterval value
2485+
2486+
Returns
2487+
-------
2488+
WOQLQuery object
2489+
query object that can be chained and/or execute
2490+
"""
2491+
if start is None or duration is None or interval_val is None:
2492+
raise ValueError("IntervalStartDuration takes three parameters")
2493+
if self._cursor.get("@type"):
2494+
self._wrap_cursor_with_and()
2495+
self._cursor["@type"] = "IntervalStartDuration"
2496+
self._cursor["start"] = self._clean_object(start)
2497+
self._cursor["duration"] = self._clean_object(duration)
2498+
self._cursor["interval"] = self._clean_object(interval_val)
2499+
return self
2500+
2501+
def interval_duration_end(self, duration, end, interval_val):
2502+
"""Relates an xdd:dateTimeInterval to its end endpoint and precise xsd:duration.
2503+
2504+
Bidirectional: given interval extracts duration+end, given
2505+
duration+end computes interval.
2506+
2507+
Parameters
2508+
----------
2509+
duration : str or dict
2510+
the xsd:duration between start and end
2511+
end : str or dict
2512+
exclusive end date or dateTime
2513+
interval_val : str or dict
2514+
the xdd:dateTimeInterval value
2515+
2516+
Returns
2517+
-------
2518+
WOQLQuery object
2519+
query object that can be chained and/or execute
2520+
"""
2521+
if duration is None or end is None or interval_val is None:
2522+
raise ValueError("IntervalDurationEnd takes three parameters")
2523+
if self._cursor.get("@type"):
2524+
self._wrap_cursor_with_and()
2525+
self._cursor["@type"] = "IntervalDurationEnd"
2526+
self._cursor["duration"] = self._clean_object(duration)
2527+
self._cursor["end"] = self._clean_object(end)
2528+
self._cursor["interval"] = self._clean_object(interval_val)
2529+
return self
2530+
24712531
def day_after(self, date, next_date):
24722532
"""Computes the calendar day after the given date. Bidirectional.
24732533

0 commit comments

Comments
 (0)