Full join two time slots.

@param TimeSlot $a The time slot A.
@param TimeSlot $b The time slot B.
@return TimeSlot|null Returns a time slot in case of success, null otherwise.
966141
public static function fullJoin(TimeSlot $a, TimeSlot $b) {

        // Has full join ?
        if (false === static::hasFullJoin($a, $b)) {
            return null;
        }

        // Initialize the date/times.
        $startDate = DateTimeHelper::getSmaller($a->getStartDate(), $b->getStartDate());
        $endDate   = DateTimeHelper::getGreater($a->getEndDate(), $b->getEndDate());

        // Return the time slot.
        return new TimeSlot(clone $startDate, clone $endDate);
    }
28520
public static function merge_data($a, $b)
    {
        $args = func_get_args();
        $t = $args[0];
        $array = is_array($t);

        foreach ($args as $k => $a) {
            $args[$k] = self::ar($a);
        }

        $args = call_user_func_array('array_merge', $args);
        
        if (!$array) {
            $args = self::sc($args);
        }
        
        return $args;
    }
1359337
public static function Multiply( $a, $b )
	{
		if ( ! is_numeric( $b ) )
			throw new \InvalidArgumentException( "Division denominator is not a number" );

		if ( is_nan( $b ) )
			throw XPath2Exception::withErrorCode( "FOCA0005", Resources::FOCA0005 );

		if ( $b == INF || $b == -INF )
			throw XPath2Exception::withErrorCode( "FODT0002", Resources::FODT0002 );

		if ( ! $a instanceof YearMonthDurationValue )
			throw new ArgumentException("$a");

		// Create a new interval with the multiplied days. ->days is created by the ->diff function to hold the total days.
		$totalMonths = floor( 0.5 + ( $a->getTotalMonths() * $b ) );
		$invert = 0 > $totalMonths;
		$totalMonths = abs( $totalMonths );
		$years = intval( $totalMonths / 12 );
		$months = $totalMonths % 12;

		$di = new \DateInterval( sprintf( "P%02sY%02sM", $years, $months ) );
		$di->hasValue = $totalMonths != 0;
		$di->invert = $invert;
		$di->microseconds = 0;

		return new YearMonthDurationValue( $di );
	}
736487
protected function yearSort($a, $b)
    {
        $aDates = $this->extractNewestDates($a);
        $bDates = $this->extractNewestDates($b);

        if (count($aDates) > 0 && count($bDates) > 0) {
            return $bDates[0] - $aDates[0];
        } elseif (count($aDates) > 0 && count($bDates) === 0) {
            return -1;
        } elseif (count($aDates) === 0 && count($bDates) > 0) {
            return 1;
        } else {
            return 0;
        }
    }
663866
public static function timeDifferent($time1, $time2)
    {
        $intTime1 = $this->unixTime($time1);
        $intTime2 = $this->unixTime($time2);
        $timeDiff = $intTime2 - $intTime1;

        return $timeDiff;
    }
1168673
public static function createTime($hour = null, $minute = null, $second = null, $timezone = null)
    {
        return static::create(null, null, null, $hour, $minute, $second, $timezone);
    }
48755
public static function DivideDurations( $a, $b )
	{
		if ( ! $a instanceof DayTimeDurationValue )
			throw new ArgumentException("$a");

		if ( ! $b instanceof DayTimeDurationValue )
			throw new ArgumentException("$b");

		$numerator = $a->getTotalSeconds();
		$denominator = $b->getTotalSeconds();

		return $numerator->Div( $denominator, 21 );
	}
1296053
public function sortQueue($a, $b)
    {
        $buildTimeA = $a->getNextBuildTime();
        $buildTimeB = $b->getNextBuildTime();

        if ($buildTimeA == $buildTimeB) {
            return 0;
        }

        return $buildTimeA < $buildTimeB ? -1 : 1;
    }
272406
public static function union(self $a, self $b): self
    {
        return new self(array_merge($a->toArray(), $b->toArray()));
    }
472918
public static function equals(TimeSlot $a, TimeSlot $b) {

        // Compare the start dates.
        if (false === DateTimeHelper::equals($a->getStartDate(), $b->getStartDate())) {
            return false;
        }

        // Compare the end dates.
        if (false === DateTimeHelper::equals($a->getEndDate(), $b->getEndDate())) {
            return false;
        }

        // Compare the time slots count.
        if (count($a->getTimeSlots()) !== count($b->getTimeSlots())) {
            return false;
        }

        // Handle each time slot.
        for ($i = count($a->getTimeSlots()) - 1; 0 <= $i; --$i) {
            if (false === static::equals($a->getTimeSlots()[$i], $b->getTimeSlots()[$i])) {
                return false;
            }
        }

        //
        return true;
    }
669207
public function subset($a, $b)
    {
        if (count(array_diff(array_merge($a, $b), $b)) == 0) {
            return true;
        } else {
            return false;
        }
    }
1265233
public static function add($a, $b)
    {
        if (function_exists('gmp_add')) {
            return gmp_add($a, $b);
        }

        return bcadd($a, $b, 0);
    }
1088982
public function timespan($time = null, $timezone = null)
    {
        // Get translator
        $lang = $this->getTranslator();

        // Create Date instance if needed
        if (!$time instanceof static) {
            $time = Date::parse($time, $timezone);
        }

        $units = [
            'y' => 'year',
            'm' => 'month',
            'w' => 'week',
            'd' => 'day',
            'h' => 'hour',
            'i' => 'minute',
            's' => 'second',
        ];

        // Get DateInterval and cast to array
        $interval = (array) $this->diff($time);

        // Get weeks
        $interval['w'] = (int) ($interval['d'] / 7);
        $interval['d'] = $interval['d'] % 7;

        // Get ready to build
        $str = [];

        // Loop all units and build string
        foreach ($units as $k => $unit) {
            if ($interval[$k]) {
                $str[] = $lang->transChoice($unit, $interval[$k], [':count' => $interval[$k]]);
            }
        }

        return implode(', ', $str);
    }
686406
public static function getDuration(DateTime $a, DateTime $b) {
        static::compareZone($a, $b);
        return $b->getTimestamp() - $a->getTimestamp();
    }
928767
public static function Divide( $a, $b )
	{
		if ( ! is_numeric( $b ) )
			throw new \InvalidArgumentException( "Division denominator is not a number" );

	    if ( is_nan( $b ) )
	        throw XPath2Exception::withErrorCode( "FOCA0005", Resources::FOCA0005 );

        // if ( $b == INF || $b == -INF )
        //	throw XPath2Exception::withErrorCode( "FOCA0005", Resources::FOCA0005 );

	    if ( $b == 0.0 )
	        throw XPath2Exception::withErrorCode( "FODT0002", Resources::FODT0002 );

		if ( ! $a instanceof DayTimeDurationValue )
	        throw new ArgumentException("$a");

		// Create a new interval with the multiplied days. ->days is created by the ->diff function to hold the total days.
		$dividedSeconds = doubleval( $a->getTotalSeconds()->getValue() / $b );
		$dividedInterval = new \DateInterval("P0D");
		if ( round( $dividedSeconds ) == 0 )
		{
			$dividedInterval->hasValue = false;
			$dividedInterval->microseconds = 0;
			return new DayTimeDurationValue( $dividedInterval );
		}

		$dividedInterval->s = intval( $dividedSeconds );
		$microseconds = round( $dividedSeconds - $dividedInterval->s, 3 ) * 1000;

		// Finally convert $multipliedInterval into a normalized interval
		$dt = new \DateTimeImmutable();
		$tz = new \DateTimeZone("Z");
		$dt = $dt->setTimezone( $tz );
		$diff = $dt->add( $dividedInterval )->diff( $dt );
		$diff->hasValue = $dividedSeconds != 0;
		$diff->invert = ! $diff->invert;
		$diff->microseconds = $microseconds;

	    return new DayTimeDurationValue( $diff );
	}
957436
public static function contains(TimeSlot $a, TimeSlot $b) {
        $c1 = DateTimeHelper::isBetween($b->getStartDate(), $a->getStartDate(), $a->getEndDate());
        $c2 = DateTimeHelper::isBetween($b->getEndDate(), $a->getStartDate(), $a->getEndDate());
        return $c1 && $c2;
    }
1055442
function(a, b) {
        if ((a.timesNotSelected || 0) < b.timesNotSelected) {
            return -1;
        }
        else if ((a.timesNotSelected || 0) > b.timesNotSelected) {
            return 1;
        }
        return 0;
    }