@@ -2655,6 +2655,36 @@ def iso_week(self, date, year, week):
26552655 self ._cursor ["week" ] = self ._clean_object (week )
26562656 return self
26572657
2658+ def date_duration (self , start , end , duration ):
2659+ """Tri-directional duration arithmetic for dates and dateTimes.
2660+ Given any two of start, end, and duration, computes the third.
2661+ Uses EOM preservation: last day of month maps to last day of target month.
2662+ Accepts xsd:date or xsd:dateTime for start/end, xsd:duration for duration.
2663+
2664+ Parameters
2665+ ----------
2666+ start : str or dict
2667+ the start date or dateTime
2668+ end : str or dict
2669+ the end date or dateTime
2670+ duration : str or dict
2671+ the xsd:duration between start and end
2672+
2673+ Returns
2674+ -------
2675+ WOQLQuery object
2676+ query object that can be chained and/or execute
2677+ """
2678+ if start is None or end is None or duration is None :
2679+ raise ValueError ("DateDuration takes three parameters" )
2680+ if self ._cursor .get ("@type" ):
2681+ self ._wrap_cursor_with_and ()
2682+ self ._cursor ["@type" ] = "DateDuration"
2683+ self ._cursor ["start" ] = self ._clean_object (start )
2684+ self ._cursor ["end" ] = self ._clean_object (end )
2685+ self ._cursor ["duration" ] = self ._clean_object (duration )
2686+ return self
2687+
26582688 def opt (self , query = None ):
26592689 """The Query in the Optional argument is specified as optional
26602690
0 commit comments