5
5
use DruidFamiliar \Abstracts \AbstractTaskParameters ;
6
6
use DruidFamiliar \Exception \MissingParametersException ;
7
7
use DruidFamiliar \Interfaces \IDruidQueryParameters ;
8
+ use DruidFamiliar \DruidTime ;
8
9
use DruidFamiliar \Interval ;
9
10
10
11
/**
@@ -227,11 +228,34 @@ public function setIntervals(Interval $intervals)
227
228
}
228
229
229
230
/**
230
- * @param Interval $intervals
231
+ * @param string|\DateTime|DruidTime $intervalStart
232
+ * @param string|\DateTime|DruidTime $intervalEnd
231
233
*/
232
234
public function setIntervalByStartAndEnd ($ intervalStart , $ intervalEnd )
233
235
{
234
- $ this ->intervals = new Interval ($ intervalStart , $ intervalEnd );
236
+ $ this ->setIntervals ( new Interval ($ intervalStart , $ intervalEnd) );
235
237
}
236
238
239
+ /**
240
+ * Adjusts the datetime to make the interval "exclusive" of the datetime.
241
+ * e.g., given
242
+ * startDateTime=2014-06-18T12:30:01Z and
243
+ * endDateTime=2014-06-18T01:00:00Z
244
+ * return and Interval containing
245
+ * startDateTime=2014-06-18T12:30:00Z and
246
+ * endDateTime=2014-06-18T01:00:01Z
247
+ *
248
+ * @param $startDateTime
249
+ * @param $endDateTime
250
+ * @return void
251
+ */
252
+ public function setIntervalForQueryingUsingExclusiveTimes ($ startDateTime , $ endDateTime )
253
+ {
254
+ $ adjustedStartDateTime = new \DateTime ($ startDateTime );
255
+ $ adjustedStartDateTime ->sub (new \DateInterval ('PT1S ' ));
256
+ $ adjustedEndDateTime = new \DateTime ($ endDateTime );
257
+ $ adjustedEndDateTime ->add (new \DateInterval ('PT1S ' ));
258
+
259
+ $ this ->setIntervals (new Interval ($ adjustedStartDateTime , $ adjustedEndDateTime ));
260
+ }
237
261
}
0 commit comments