Converts to seconds.

@param string $unit
@param float  $value

@return float
504201
public function convertTime(string $unit, float $value)
    {
        if ($unit === 'seconds') {
            return $value;
        }

        if ($unit === 'minutes') {
            return $value * (60);
        }

        if ($unit === 'hours') {
            return $value * (3600);
        }

        if ($unit === 'days') {
            return $value * (86400);
        }

        if ($unit === 'weeks') {
            return $value * (7 * 86400);
        }

        if ($unit === 'months') {
            return $value * (30 * 86400);
        }

        if ($unit === 'years') {
            return $value * (365 * 86400);
        }

        throw new \Exception('Wrong frequencies');
    }
620795
public function shiftTimezone($value)
    {
        $offset = $this->offset;
        $date = $this->setTimezone($value);

        return $date->addRealMicroseconds(($offset - $date->offset) * static::MICROSECONDS_PER_SECOND);
    }
1009062
public static function convertToEdmDateTime($value)
    {
        if (empty($value)) {
            return $value;
        }

        if (is_string($value)) {
            $value = self::convertToDateTime($value);
        }

        Validate::isDate($value, 'value');

        $cloned = clone $value;
        $cloned->setTimezone(new \DateTimeZone('UTC'));

        return str_replace('+0000', 'Z', $cloned->format(\DateTime::ISO8601));
    }
203293
protected function toBase($value, array $unit)
    {
        if (is_callable($unit['conversion'])) {
            return $unit['conversion']($value, false);
        }

        return $value * $unit['conversion'];
    }
893570
public static function convertTo($value, $unitFrom, $unitTo)
    {
        if ($unitTo == $unitFrom) {
            return $value;
        }
        return ($value * $unitFrom) / $unitTo;
    }
922078
protected Float convertFloat(String value, String unit, int unary)
			throws IllegalArgumentException {

		try {
            if (unit != null)
            {
    			// trim & lowercase
    			value = value.trim().toLowerCase();
    			// trim units from value
                if (value.endsWith(unit))
                    value = value.substring(0, value.length() - unit.length());
            }

			return Float.parseFloat(value) * unary;
		} catch (NumberFormatException e) {
			throw new IllegalArgumentException(
					"Invalid number format " + value, e);
		} catch (NullPointerException e) {
			throw new IllegalArgumentException("Invalid null format");
		}
	}
455161
public function getDateTime(int $value): DateTime
    {
        if ($value > 9999999999) { // microseconds it is
            $value = floor($value / 1000000);
        }

        return DateTime::createFromFormat("U", $value);
    }
1305171
private function timestampFromBigQuery($value)
    {
        // If the string contains 'E' convert from exponential notation to
        // decimal notation. This doesn't cast to a float because precision can
        // be lost.
        if (strpos($value, 'E')) {
            list($value, $exponent) = explode('E', $value);
            list($firstDigit, $remainingDigits) = explode('.', $value);

            if (strlen($remainingDigits) > $exponent) {
                $value = $firstDigit . substr_replace($remainingDigits, '.', $exponent, 0);
            } else {
                $value = $firstDigit . str_pad($remainingDigits, $exponent, '0') . '.0';
            }
        }

        $parts = explode('.', $value);
        $unixTimestamp = $parts[0];
        $microSeconds = isset($parts[1])
            ? $parts[1]
            : 0;

        $dateTime = new \DateTime("@$unixTimestamp");

        // If the timestamp is before the epoch, make sure we account for that
        // before concatenating the microseconds.
        if ($microSeconds > 0 && $unixTimestamp[0] === '-') {
            $microSeconds = 1000000 - (int) str_pad($microSeconds, 6, '0');
            $dateTime->modify('-1 second');
        }

        return new Timestamp(
            new \DateTime(
                sprintf(
                    '%s.%s+00:00',
                    $dateTime->format('Y-m-d H:i:s'),
                    $microSeconds
                )
            )
        );
    }
1359718
public function convert($value)
    {
        if (!is_scalar($value)) {
            return false;
        }

        if (is_string($value)) {
            return $value;
        }

        if (is_float($value)) {
            return sprintf('float_%.4f', $value);
        }

        $prefix = '';

        if (!is_bool($value)) {
            $prefix = gettype($value) . '_';
        }

        
        return $prefix . var_export($value, true);
    }
1202870
public static function toFloat($value)
    {
        if (!static::is($value)) {
            throw new \InvalidArgumentException(
                "The \$value parameter must be numeric (or string representing a big number)."
            );
        }

        if (is_int($value) || is_float($value)) {
            return (float)$value;
        } else {
            return ((Str::contains($value, '.')) ? $value : $value . '.0');
        }
    }
478342
public function setTtl(int $seconds, string $value = '')
        {
                if(!empty($value)) {
                        return $this->_redis->setex($this->_key, $seconds, $value);
                }
                return parent::setExpire($seconds);
        }
748823
public static function standardToDecimalTime($value) {
		$base = (int)$value;
		$tmp = $value - $base;

		$tmp *= 100;
		$tmp *= 1 / 60;

		$value = $base + $tmp;
		return $value;
	}
191545
public function joinTimeWindow($value, $unit, $required = false)
    {
        if (is_int($value)) {
            $v = $value;
        } elseif (is_string($value) && trim($value) !== '' && is_numeric(trim($value))) {
            $v = (int) $value;
        } else {
            $v = null;
        }
        if ($v === null) {
            if ($required) {
                throw new UserMessageException(t('The value of the time window is missing'));
            }
            $result = null;
        } elseif ($v <= 0) {
            throw new UserMessageException(t('The value of the time window must be greater than zero'));
        } else {
            if (is_int($unit)) {
                $u = $unit;
            } elseif (is_string($unit) && trim($unit) !== '' && is_numeric(trim($unit))) {
                $u = (int) $unit;
            } else {
                $u = null;
            }
            if ($u === null || !array_key_exists($u, $this->getTimeWindowUnits())) {
                throw new UserMessageException(t('The value of the time window units is not valid'));
            }
            $result = $u * $v;
            if (!is_int($result)) {
                throw new UserMessageException(t('The value of the time window units is too big'));
            }
        }

        return $result;
    }
732038
protected function _calculationValue($unit) {
		if (!isset($this->_Calculator)) {
			$this->_Calculator = new Calculator();
		}
		return $this->_Calculator->convert(6371.04, Calculator::UNIT_KM, $unit);
	}
20950
public function from($value, $unit)
    {
        $this->base_unit = $this->value = null;

        $key = strtolower($unit);

        if (empty($this->units[$key]['base'])) {
            throw new OutOfBoundsException('Unit does not exist');
        }

        if (!isset($this->units[$key]['conversion'])) {
            throw new OutOfBoundsException("Conversion is not set for unit $unit");
        }

        $this->base_unit = $this->units[$key]['base'];
        $this->value = $this->toBase($value, $this->units[$key]);
        return $this;
    }
1211506
static public function toUnixtime($value=null)
    {
        return (empty($value)) ? time() : (is_numeric($value) ? $value : strtotime($value));
    }
491627
public static function convert(float $time, string $unit, string $destUnit, string $mode)
    {
        self::validateMode($mode);

        if ($mode === self::MODE_TIME) {
            return self::convertTo($time, $unit, $destUnit);
        }

        return self::convertInto($time, $unit, $destUnit);
    }