1 | <?php |
||
15 | class Time |
||
16 | { |
||
17 | /** |
||
18 | * Convert seconds to decimal time format. |
||
19 | * |
||
20 | * @param int $seconds |
||
21 | * |
||
22 | * @return float |
||
23 | */ |
||
24 | 2 | public static function secondsToDecimal(int $seconds) |
|
30 | |||
31 | /** |
||
32 | * Convert elapsed time from "H:i:s" to decimal equivalent. |
||
33 | * |
||
34 | * @param string $time "12:00:00" |
||
35 | * |
||
36 | * @return float |
||
37 | */ |
||
38 | 2 | public static function timeToDecimal(string $time) |
|
43 | |||
44 | /** |
||
45 | * Format elapsed time to short display value. |
||
46 | * |
||
47 | * @param float $decTime time in decimal format 1.5 = 1h 30m |
||
48 | * @param string $type hour text format 'short' or 'full' |
||
49 | * @param int|bool $withSeconds if is provided as int then will be displayed |
||
50 | * |
||
51 | * @return string |
||
52 | */ |
||
53 | 2 | public static function formatToHourText($decTime, $type = 'short', $withSeconds = false) |
|
76 | } |
||
77 |