concrete/src/Form/Service/Widget/DateTime.php
protected function selectNearestValue(array $values, $wantedValue)
    {
        if (in_array($wantedValue, $values)) {
            $result = $wantedValue;
        } else {
            $result = null;
            $minDelta = PHP_INT_MAX;
            foreach ($values as $value) {
                $delta = abs($value - $wantedValue);
                if ($delta < $minDelta) {
                    $minDelta = $delta;
                    $result = $value;
                }
            }
        }

        return $result;
    }
protected function selectNearestValue(array $values, $wantedValue)
    {
        if (in_array($wantedValue, $values)) {
            $result = $wantedValue;
        } else {
            $result = null;
            $minDelta = PHP_INT_MAX;
            foreach ($values as $value) {
                $delta = abs($value - $wantedValue);
                if ($delta < $minDelta) {
                    $minDelta = $delta;
                    $result = $value;
                }
            }
        }

        return $result;
    }
protected function selectNearestValue ( array $ values , $ wantedValue ) { if ( in_array ( $ wantedValue , $ values ) ) { $ result = $ wantedValue ; } else { $ result = null ; $ minDelta = PHP_INT_MAX ; foreach ( $ values as $ value ) { $ delta = abs ( $ value - $ wantedValue ) ; if ( $ delta < $ minDelta ) { $ minDelta = $ delta ; $ result = $ value ; } } } return $ result ; }
Choose an array value nearest to a specified value.
Useful when we work with time resolutions.

@param int $values
@param int $wantedValue

@return int

@example If the current time is 10 and the time resolution is 15, we have an array of values of [0, 15, 30, 45]: the closest value is 15.
Choose an array value nearest to a specified value . Useful when we work with time resolutions .