Parse decimal degrees coordinate to degrees minutes seconds and decimal minutes coordinate.

@param string $coordinate The coordinate to parse.

@return array The replace pairs values.
964513
private function parseCoordinate($coordinate)
    {
        list($degrees) = explode('.', abs($coordinate));
        list($minutes) = explode('.', (abs($coordinate) - $degrees) * 60);

        return [
            'positive'       => $coordinate >= 0,
            'degrees'        => (string) $degrees,
            'decimalMinutes' => (string) round((abs($coordinate) - $degrees) * 60,
                ConvertInterface::DECIMAL_MINUTES_PRECISION,
                ConvertInterface::DECIMAL_MINUTES_MODE),
            'minutes'        => (string) $minutes,
            'seconds'        => (string) round(((abs($coordinate) - $degrees) * 60 - $minutes) * 60),
        ];
    }
422642
protected function secondsToString($seconds)
    {
        $seconds = (int) $seconds;

        $time = array();

        // get hours
        $hours = floor($seconds / 3600);
        $time[] = str_pad($hours, 2, '0', STR_PAD_LEFT);

        // get minutes
        $seconds = $seconds % 3600;
        $time[] = str_pad(floor($seconds / 60), 2, '0', STR_PAD_LEFT);

        // get seconds
        $time[] = str_pad($seconds % 60, 2, '0', STR_PAD_LEFT);

        return implode(':', $time);
    }
163027
public function duration($seconds)
    {
        $result = [
            'hour'     => (int) floor($seconds / 3600),
            'min'      => (int) floor(($seconds / 60) % 60),
            'sec'      => $seconds % 60,
            'ms'       => (int) round(\fmod($seconds, 1) * 1000),
        ];

        $duration = '';
        foreach ($result as $unit => $value) {
            if (!empty($value) || $unit === 'ms') {
                $duration .= $value . "$unit ";
            }
        }

        $result['duration'] = trim($duration);

        return $result;
    }
961244
protected function _decode($source)
    {
        // entity decode
        $trans_tbl = get_html_translation_table(HTML_ENTITIES);
        foreach ($trans_tbl as $k => $v) {
            $ttr[$v] = utf8_encode($k);
        }
        $source = strtr($source, $ttr);

        // convert decimal
        //$source = preg_replace('/&#(\d+);/me', "chr(\\1)", $source); // decimal notation
        $source = preg_replace_callback(
                       '/&#(\d+);/m',
                       function ($m) {
                           return chr($m[1]);
                       },
                       $source
        );

        // convert hex
        //$source = preg_replace('/&#x([a-f0-9]+);/mei', "chr(0x\\1)", $source); // hex notation
        
        $source = preg_replace_callback(
                       '/&#x([a-f0-9]+);/mi',
                       function ($m) {
                           return chr('0x'.$m[1]);
                       },
                       $source
        );
        
        return $source;
    }
1204565
public static function toFloat($string)
    {
        $lc = localeconv();

        $string = self::parseNegativeNotation($string);

        // change all locale formatting to numeric formatting
        $remove_parts = array(
            $lc['decimal_point'] => '.',
            $lc['positive_sign'] => '',
            $lc['thousands_sep'] => ''
        );

        $value = str_replace(
            array_keys($remove_parts),
            array_values($remove_parts),
            $string
        );

        // note: This might be done better with a regexp, though
        // checking too closely how well a number matches its locale
        // formatting could become annoying too. i.e. if 1000 was
        // rejected because it wasn't formatted 1,000

        return is_numeric($value) ? floatval($value) : null;
    }
1097410
static function parsePoint($source)
    {
        $point = new Point;

        if (isset($source['time'])) {
            $point->setTime(new \DateTime($source['time']));
        }

        if (isset($source['lat'])) {
            $point->setLatitude($source['lat']);
        }

        if (isset($source['lng'])) {
            $point->setLongitude($source['lng']);
        }

        if (isset($source['alt'])) {
            $point->setAltitude($source['alt']);
        }

        if (isset($source['dist'])) {
            $point->setDistance($source['dist']);
        }

        if (isset($source['speed'])) {
            $point->setSpeed($source['speed']);
        }

        if (isset($source['duration'])) {
            $point->setDuration($source['duration']);
        }

        if (isset($source['hr'])) {
            $point->setHeartRate($source['hr']);
        }

        if (isset($source['inst'])) {
            $point->setInstruction($source['inst']);
        }

        return $point;
    }
1350672
public static function getDurations(int $precision = -1): array
    {
        $ret = [];
        foreach (self::$timers as $t) {
            Arr::addValue($ret, $t->getName(), $t->getDuration($precision));
        }
        return $ret;
    }
348777
public static function parse(string $number) : Decimal
    {
        if (preg_match('/^(\-?)([0-9]+)(?:\.([0-9]+))?$/', $number, $matches) !== 1) {
            throw new \InvalidArgumentException('Invalid number: ' . $number);
        }

        $sign = $matches[1];
        $integral = $matches[2];

        if (isset($matches[3])) {
            $fractional = rtrim($matches[3], '0');
        } else {
            $fractional = '';
        }

        $scale = strlen($fractional);

        $value = $integral . $fractional;
        $value = ltrim($value, '0');

        if ($value === '') {
            $value = '0';
        }

        $value = $sign . $value;

        $intValue = (int) $value;

        if ($value !== (string) $intValue) {
            throw new \InvalidArgumentException('Decimal number out of range for this platform: ' . $value);
        }

        return new Decimal($intValue, $scale);
    }
356840
public function getDigits(array $decimals)
    {
        $digits = [];

        foreach ($decimals as $decimal) {
            $digits[] = $this->digits->getDigit($decimal);
        }

        return $digits;
    }
853006
static function parserDateTime($dateTime)
    {
        if (!$dateTime instanceof \DateTime) $dateTime = static::createDateTimeClass($dateTime);
        $year = $dateTime->format('Y');
        $day = $dateTime->format('j');
        $month = $dateTime->format('n');
        $hour = $dateTime->format('H');
        $minute = $dateTime->format('i');
        $second = $dateTime->format('s');
        return [ $hour, $minute, $second, $month, $day, $year ];
    }
445237
public function getGMT(string $prefix = self::GMT): string
    {
        list($hour, $minute, $sign) = $this->getUtcParts($this->offset);
        return $prefix.$sign.$hour.$minute;
    }
790467
public function guessParser($coord) {
        if (!is_numeric($coord) and !is_null($coord)) {
            return new C\DmsParser;
        }
        return new C\DecimalParser;
    }
1217571
public static function parse(string $string): TimeInterface
    {
        $bits = explode(":", $string);

        $seconds = (int) array_pop($bits);

        $minutes = (int) array_pop($bits);
        $seconds += ($minutes * 60);

        $hours = (int) array_pop($bits);
        $seconds += ($hours * 60 * 60);

        return new self($seconds);
    }
30203
public static String formatCoordinate(double coordinate) {
    DecimalFormat decimalFormat = new DecimalFormat("0.######",
      new DecimalFormatSymbols(Locale.US));
    return String.format(Locale.US, "%s",
      decimalFormat.format(coordinate));
  }
1325788
protected function parsePeriodFromDates($period)
    {
        if (substr_count($period, '-') != 1) {
            throw new Exception("Expecting 'date1-date2' syntax");
        }

        $result = [
            'min' => null,
            'max' => null,
        ];

        list($result['min'], $result['max']) = explode('-', $period);

        foreach ($result as $key => $value) {
            if (!$value) {
                $result[$key] = null;
                continue;
            }

            $result[$key] = new DateTime($value, $this->getTimezoneFrom());
        }

        return $result;
    }
236917
public function format($decimals = 0, $decPoint = '.', $thousandsSep = ' ')
    {
        $decimals = max(0, (int) $decimals);
        $dec      = '';
        // do not mutate
        $number   = (new static($this))->round($decimals)->normalize();
        $sign     = $number->isPositive() ? '' : '-';
        if ($number->abs()->hasDecimals()) {
            list($number, $dec) = explode('.', (string) $number);
        }

        if ($decimals) {
            $dec = sprintf("%'0-" . $decimals . 's', $dec);
        }

        return $sign . preg_replace("/(?<=\d)(?=(\d{3})+(?!\d))/", $thousandsSep, $number) . ($decimals ? $decPoint . $dec : '');
    }
470856
public static function SecondsFromDuration( $arg )
	{
		if ( $arg instanceof Undefined )
			return Undefined::getValue();

		/**
		 * @var DurationValue $duration
		 */
		$duration = $arg;

		return DecimalValue::FromValue( $duration->getSeconds() * ( $duration->getInverted() ? -1 : 1 ) );
	}