@@ -4978,6 +4978,21 @@ public static int customDateAdd(DataContext root,
4978
4978
return timeFrameSet .addDate (date , interval , timeFrame );
4979
4979
}
4980
4980
4981
+ /** SQL {@code DATEADD} function applied to a custom time frame.
4982
+ *
4983
+ * <p>Custom time frames are created as part of a {@link TimeFrameSet}.
4984
+ * This method retrieves the session's time frame set from the
4985
+ * {@link DataContext.Variable#TIME_FRAME_SET} variable, then looks up the
4986
+ * time frame by name. */
4987
+ public static int customDateAdd (DataContext root ,
4988
+ TimeUnitRange timeFrameName , int interval , int date ) {
4989
+ final TimeFrameSet timeFrameSet =
4990
+ requireNonNull (DataContext .Variable .TIME_FRAME_SET .get (root ));
4991
+ final TimeFrame timeFrame = timeFrameSet .get (timeFrameName .startUnit );
4992
+ return timeFrameSet .addDate (date , interval , timeFrame );
4993
+ }
4994
+
4995
+
4981
4996
/** SQL {@code TIMESTAMPADD} function applied to a custom time frame.
4982
4997
*
4983
4998
* <p>Custom time frames are created and accessed as described in
@@ -4990,6 +5005,19 @@ public static long customTimestampAdd(DataContext root,
4990
5005
return timeFrameSet .addTimestamp (timestamp , interval , timeFrame );
4991
5006
}
4992
5007
5008
+ /** SQL {@code TIMESTAMPADD} function applied to a custom time frame.
5009
+ *
5010
+ * <p>Custom time frames are created and accessed as described in
5011
+ * {@link #customDateAdd}. */
5012
+ public static long customTimestampAdd (DataContext root ,
5013
+ TimeUnitRange timeFrameName , long interval , long timestamp ) {
5014
+ final TimeFrameSet timeFrameSet =
5015
+ requireNonNull (DataContext .Variable .TIME_FRAME_SET .get (root ));
5016
+ final TimeFrame timeFrame = timeFrameSet .get (timeFrameName .startUnit );
5017
+ return timeFrameSet .addTimestamp (timestamp , interval , timeFrame );
5018
+ }
5019
+
5020
+
4993
5021
/** SQL {@code DATEDIFF} function applied to a custom time frame.
4994
5022
*
4995
5023
* <p>Custom time frames are created and accessed as described in
0 commit comments