Computes a human readable duration string from floating seconds

@param float $seconds

@return array<string,integer|string>
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;
    }
186387
protected function convertFromMinutes($minutes)
    {
        $seconds = $minutes * 60;

        $secondsInAMinute = 60;
        $secondsInAnHour  = 60 * $secondsInAMinute;
        $secondsInADay    = 24 * $secondsInAnHour;

        // extract days
        $days = floor($seconds / $secondsInADay);

        // extract hours
        $hourSeconds = $seconds % $secondsInADay;
        $hours       = floor($hourSeconds / $secondsInAnHour);

        // extract minutes
        $minuteSeconds = $hourSeconds % $secondsInAnHour;
        $minutes       = floor($minuteSeconds / $secondsInAMinute);

        // return the final string
        $output = '';

        if ($days > 0) {
            $output .= $days . ' ' . $this->pluralize('day', $days);
        }

        if ($hours > 0) {
            $output .= $hours . ' ' . $this->pluralize('hour', $hours);
        }

        $output .= $minutes . ' ' . $this->pluralize('minute', $minutes);

        return $output;
    }
1131109
protected function _secondsToHuman($seconds, $format) {
		return (new DateTime('today'))->diff(new DateTime('today +' . (int)$seconds . ' seconds'))->format($format);
	}
377001
def get_formatted_time(seconds: float) -> str:
    
    seconds = round(seconds)
    m, s = divmod(seconds, 60)
    h, m = divmod(m, 60)
    return '{:d}:{:02d}:{:02d}'.format(h, m, s)
570974
private function formatDuration($milliseconds)
    {
        $hours = floor($milliseconds / 1000 / 3600);
        $milliseconds -= ($hours * 3600 * 1000);

        $minutes = floor($milliseconds / 1000 / 60);
        $milliseconds -= ($minutes * 60 * 1000);

        $seconds = floor($milliseconds / 1000);
        $milliseconds -= ($seconds * 1000);

        $values = [
            'hour' => $hours,
            'minute' => $minutes,
            'second' => $seconds,
            'millisecond' => $milliseconds,
        ];

        $parts = [];

        foreach ($values as $text => $value) {
            if ($value > 0) {
                $parts[] = $value.' '.$text.($value > 1 ? 's' : '');
            }
        }

        return implode(' ', $parts);
    }
857030
public static function formatTime($micros)
    {
        $seconds = $micros;
        $minutes = (int) floor($seconds / 60);
        if ($minutes >= 1) {
            return sprintf(
                "%1.0f minute%s %0.2f second%s",
                $minutes,
                ($minutes === 1 ? " " : "s "),
                $seconds - floor($seconds / 60) * 60,
                ($seconds % 60 === 1 ? "" : "s")
            );
        } else {
            return sprintf("%0.4f second%s", $seconds, ($seconds % 60 === 1 ? "" : "s"));
        }
    }
1110913
public function plusSeconds(int $seconds) : Duration
    {
        if ($seconds === 0) {
            return $this;
        }

        return new Duration($this->seconds + $seconds, $this->nanos);
    }
204512
private function seconds()
    {
        // Seconds value can be an integer or float
        if ($this->lexer->isNextTokenAny(array(Lexer::T_INTEGER, Lexer::T_FLOAT))) {
            $seconds = $this->number();

            // Throw exception if seconds are greater than 60
            if ($seconds > 60) {
                throw $this->rangeError('Seconds', 60);
            }

            // Get fractional seconds
            $seconds /= 3600;

            // Match seconds symbol if requirement not colon
            if (Lexer::T_COLON !== $this->nextSymbol) {
                $this->symbol();
            }

            // Return value
            return $seconds;
        }

        // No seconds were present so return 0
        return 0;
    }
811002
public static function formatSeconds($seconds)
    {
        $format = '';
        $rest = $seconds;
        if ($seconds >= 86400) {
            $format .= floor($seconds/86400).'d ';
            $rest = $seconds%86400;
        }

        if ($rest >= 3600) {
            $format .= floor($rest/3600).'h ';
            $rest = $rest%3600;
        }

        if ($rest >= 60) {
            $format .= floor($rest/60) . 'min ';
            $rest = $rest%60;
        }

        if ($rest > 0) {
            $format .= $rest . 'sec ';
        }

        return trim($format);
    }
590747
public function setWritingTimeout(float $seconds): self
    {
        $this->validateTimeout($seconds);
        $this->writingTimeout = $seconds;

        return $this;
    }
631211
public static function time($seconds)
    {
        if ($seconds < 0) {
            return "n/a";
        }

        if ($seconds < 60) {
            return $seconds . " Seconds";
        }

        $minutes = floor($seconds / 60);
        $seconds = $seconds % 60;

        if ($minutes < 60) {
            if ($seconds >= 30) {
                $minutes++;
            }
            return $minutes . " Minutes";
        }

        $hours = floor($minutes / 60);
        $minutes = $minutes % 60;

        if ($hours < 24) {
            if ($minutes >= 30) {
                $hours++;
            }
            return $hours . " Hours";
        }

        $days = floor($hours / 24);
        $hours = $hours % 24;

        if ($hours >= 12) {
            $days++;
        }

        return $days . " Days";
    }
943460
public static String secondsToHoursMinutesSeconds(final long secs)
        {
        final double minutesRemaining = (secs / 60) % 60;
        final double hoursRemaining = Math.floor(secs / 60 / 60);
        final double secondsRemaining = secs % 60;
        
        final StringBuilder sb = new StringBuilder();
        if (hoursRemaining > 0.0)
            {
            sb.append((int)hoursRemaining);
            sb.append(" hrs, ");
            }
        if (minutesRemaining > 0.0)
            {
            sb.append((int)minutesRemaining);
            sb.append(" mins, ");
            }
        sb.append((int)secondsRemaining);
        sb.append(" secs");
        return sb.toString();
        }
898132
public function cache($seconds = null)
    {
        if ($seconds === null) {
            $this->cacheTime = $this->defaultCacheTime;
        } elseif ($seconds === false) {
            $this->cacheTime = false;
        } else {
            $this->cacheTime = (int)$seconds;
        }
        return $this;
    }
744612
public function & SetExpirationSeconds ($seconds = 0) {
		/** @var $this \MvcCore\Session */
		if ($seconds > 0) 
			static::$meta->expirations[$this->__name] = static::$sessionStartTime + $seconds;
		return $this;
	}
487713
public function getMinutesAsHours($minutes)
    {
        $hours = floor($minutes / 60);
        $minutes = $minutes - ($hours * 60);

        return sprintf('%s:%s', $hours, str_pad($minutes, 2, '0', STR_PAD_LEFT));
    }
899540
private function formatDuration(float $duration): string {
        if ($duration < 1.0e-3) {
            $n = number_format($duration * 1.0e6, 0);
            $sx = 'μs';
        } elseif ($duration < 1) {
            $n = number_format($duration * 1000, 0);
            $sx = 'ms';
        } elseif ($duration < 60) {
            $n = number_format($duration, 1);
            $sx = 's';
        } elseif ($duration < 3600) {
            $n = number_format($duration / 60, 1);
            $sx = 'm';
        } elseif ($duration < 86400) {
            $n = number_format($duration / 3600, 1);
            $sx = 'h';
        } else {
            $n = number_format($duration / 86400, 1);
            $sx = 'd';
        }

        $result = rtrim($n, '0.').$sx;
        return $result;
    }
1177348
public function time_hms($seconds)
	{
		$time = '';

		// First pass
		$hours = (int) ($seconds / 3600);
		$seconds = $seconds % 3600;
		$minutes = (int) ($seconds / 60);
		$seconds = $seconds % 60;

		// Cleanup
		$time .= ($hours) ? $hours . ':' : '';
		$time .= ($minutes < 10 && $hours > 0) ? '0' . $minutes : $minutes;
		$time .= ':';
		$time .= ($seconds < 10) ? '0' . $seconds : $seconds;

		return $time;
	}