Exemple #1
0
 /**
  * Function to get the date values for the given type of Standard filter
  * @param <String> $type
  * @return <Array> - 2 date values representing the range for the given type of Standard filter
  */
 protected static function getDateForStdFilterBytype($type)
 {
     return DateTimeRange::getDateRangeByType($type);
 }
Exemple #2
0
 /** Function to get standardfilter startdate and enddate for the given type
  *  @ param $type : Type String
  *  returns the $datevalue Array in the given format
  * 		$datevalue = Array(0=>$startdate,1=>$enddate)
  */
 function getStandarFiltersStartAndEndDate($type)
 {
     return DateTimeRange::getDateRangeByType($type);
 }
Exemple #3
0
 /**
  * Casts an DateTimeRange object into DateRange.
  *
  * @param   DateTimeRange  $range  A DateTimeRange object
  *
  * @return  DateRange
  *
  * @since   2.0.0
  */
 private static function cast(DateTimeRange $range)
 {
     $start = new Date($range->start());
     $end = new Date($range->end());
     return new DateRange($start, $end);
 }
Exemple #4
0
 /** to get the date value for the given type
  * @param $type :: type string
  * @returns  $datevalue array in the following format
  *             $datevalue = Array(0=>$startdate,1=>$enddate)
  */
 function getDateforStdFilterBytype($type)
 {
     return DateTimeRange::getDateRangeByType($type);
 }
Exemple #5
0
 /**
  * Compares two objects.
  *
  * @param   DateTimeRange  $a  Base object.
  * @param   DateTimeRange  $b  Object to compare to.
  *
  * @return  integer
  *
  * @since   2.0.0
  * @throws  \InvalidArgumentException
  */
 private static function compare(DateTimeRange $a, DateTimeRange $b)
 {
     if (!$a->interval->equals($b->interval)) {
         throw new \InvalidArgumentException('Intervals of ranges are not equal.');
     }
     if ($a->equals($b)) {
         return 0;
     }
     if ($a->start()->isAfter($b->start())) {
         return 1;
     }
     if ($a->start()->isBefore($b->start()) || $a->end()->isBefore($b->end())) {
         return -1;
     }
     return 1;
 }