Conditions | 1 |
Paths | 1 |
Total Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
29 | public static function divide(\DateTime $start_date, \DateTime $end_date, \DateInterval $duration) { |
||
30 | // Clone so that we don't change the original object. We are not using ImmutableDateTime to support PHP5.4 |
||
31 | $temp_end_date = clone($end_date); |
||
32 | |||
33 | // Add a minute to deal with the fact that BAT considers the last minute included |
||
34 | $temp_end_date->add(new \DateInterval('PT1M')); |
||
35 | |||
36 | // Convert everything to seconds and calculate exactly how many times the duration fits in our event length |
||
37 | $duration_seconds = $duration->d * 86400 + $duration->h * 3600 + $duration->i * 60 + $duration->s; |
||
38 | |||
39 | $diff = $start_date->diff($temp_end_date); |
||
40 | $diff_seconds = $diff->days * 86400 + $diff->h * 3600 + $diff->i * 60 + $diff->s; |
||
41 | |||
42 | return $diff_seconds / $duration_seconds; |
||
43 | } |
||
44 | |||
46 |