Skip to content

Commit f6f313d

Browse files
committed
Add day_after/day_before
1 parent 36f038e commit f6f313d

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

terminusdb_client/woqlquery/woql_query.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2438,6 +2438,54 @@ 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 day_after(self, date, next_date):
2442+
"""Computes the calendar day after the given date. Bidirectional.
2443+
2444+
Parameters
2445+
----------
2446+
date : str or dict
2447+
the input date
2448+
next_date : str or dict
2449+
the next calendar day
2450+
2451+
Returns
2452+
-------
2453+
WOQLQuery object
2454+
query object that can be chained and/or execute
2455+
"""
2456+
if date is None or next_date is None:
2457+
raise ValueError("DayAfter takes two parameters")
2458+
if self._cursor.get("@type"):
2459+
self._wrap_cursor_with_and()
2460+
self._cursor["@type"] = "DayAfter"
2461+
self._cursor["date"] = self._clean_object(date)
2462+
self._cursor["next"] = self._clean_object(next_date)
2463+
return self
2464+
2465+
def day_before(self, date, previous):
2466+
"""Computes the calendar day before the given date. Bidirectional.
2467+
2468+
Parameters
2469+
----------
2470+
date : str or dict
2471+
the input date
2472+
previous : str or dict
2473+
the previous calendar day
2474+
2475+
Returns
2476+
-------
2477+
WOQLQuery object
2478+
query object that can be chained and/or execute
2479+
"""
2480+
if date is None or previous is None:
2481+
raise ValueError("DayBefore takes two parameters")
2482+
if self._cursor.get("@type"):
2483+
self._wrap_cursor_with_and()
2484+
self._cursor["@type"] = "DayBefore"
2485+
self._cursor["date"] = self._clean_object(date)
2486+
self._cursor["previous"] = self._clean_object(previous)
2487+
return self
2488+
24412489
def opt(self, query=None):
24422490
"""The Query in the Optional argument is specified as optional
24432491

0 commit comments

Comments
 (0)