@@ -10,8 +10,7 @@ |
||
| 10 | 10 | { |
| 11 | 11 | $date = new \DateTimeImmutable("$parm"); |
| 12 | 12 | return $date->format($format); |
| 13 | - } |
|
| 14 | - catch(\Exception $e) |
|
| 13 | + } catch(\Exception $e) |
|
| 15 | 14 | { |
| 16 | 15 | return null; |
| 17 | 16 | } |
@@ -27,8 +27,9 @@ discard block |
||
| 27 | 27 | // find the total numbers of days in full years since the mythical 1/1/0001, then add the number of days before the current one in the year passed. Do this for each date, then return the absolute value of the difference |
| 28 | 28 | public static function days_diff($a, $b, $c = 'DateTime') |
| 29 | 29 | { |
| 30 | - if(!is_a($a,$c) || !is_a($b,$c)) |
|
| 31 | - throw new \InvalidArgumentException('ARGUMENT_MUST_HAVE_SAME_TYPE'); |
|
| 30 | + if(!is_a($a,$c) || !is_a($b,$c)) { |
|
| 31 | + throw new \InvalidArgumentException('ARGUMENT_MUST_HAVE_SAME_TYPE'); |
|
| 32 | + } |
|
| 32 | 33 | return self::days($a) - self::days($b); |
| 33 | 34 | } |
| 34 | 35 | |
@@ -36,8 +37,10 @@ discard block |
||
| 36 | 37 | { |
| 37 | 38 | $lfy = $x->format('Y') - 1; // last full year |
| 38 | 39 | |
| 39 | - foreach([4, -100, 400] as $f) // leap year factors |
|
| 40 | + foreach([4, -100, 400] as $f) { |
|
| 41 | + // leap year factors |
|
| 40 | 42 | $d += ($lfy / $f); |
| 43 | + } |
|
| 41 | 44 | |
| 42 | 45 | return (int)(($lfy * 365.25) + $d + $x->format('z')); // days since 1.1.1001 from last year (+|-) leap days + days in current year |
| 43 | 46 | } |
@@ -56,8 +59,7 @@ discard block |
||
| 56 | 59 | $date_diff[$previous_part] = $amount_of_days % $limit; |
| 57 | 60 | $previous_part = $part; |
| 58 | 61 | $amount_of_days = intval($amount_of_days / $limit); |
| 59 | - } |
|
| 60 | - else |
|
| 62 | + } else |
|
| 61 | 63 | { |
| 62 | 64 | $date_diff[$previous_part] = $amount_of_days; |
| 63 | 65 | break; |