blob: c9dbeea12f3b063706f50251ec8f9973c1c9cde5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
<?php
declare(strict_types=1);
namespace Engelsystem\Helpers\Schedule;
trait CalculatesTime
{
/**
* @param string $time
* @return int
*/
protected function secondsFromTime(string $time): int
{
$seconds = 0;
$duration = explode(':', $time);
foreach (array_slice($duration, 0, 2) as $key => $times) {
$seconds += [60 * 60, 60][$key] * $times;
}
return $seconds;
}
}
|