@@ -24,24 +24,24 @@ discard block |
||
24 | 24 | return parent::format(null, $format); |
25 | 25 | } |
26 | 26 | |
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 | - public static function days_diff($a, $b, $c = 'DateTime') |
|
29 | - { |
|
30 | - return (is_a($a,$c) && is_a($b,$c)) ? self::days($a) - self::days($b) : false; |
|
31 | - } |
|
32 | - |
|
33 | - public static function days($x, $d = 0) |
|
34 | - { |
|
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 | + public static function days_diff($a, $b, $c = 'DateTime') |
|
29 | + { |
|
30 | + return (is_a($a,$c) && is_a($b,$c)) ? self::days($a) - self::days($b) : false; |
|
31 | + } |
|
32 | + |
|
33 | + public static function days($x, $d = 0) |
|
34 | + { |
|
35 | 35 | $lfy = $x->format('Y') - 1; // last full year |
36 | 36 | |
37 | - foreach([4, -100, 400] as $f) // leap year factors |
|
38 | - $d += ($lfy / $f); |
|
37 | + foreach([4, -100, 400] as $f) // leap year factors |
|
38 | + $d += ($lfy / $f); |
|
39 | 39 | |
40 | - return (int)(($lfy * 365.25) + $d + $x->format('z')); // days since 1.1.1001 from last year (+|-) leap days + days in current year |
|
41 | - } |
|
40 | + return (int)(($lfy * 365.25) + $d + $x->format('z')); // days since 1.1.1001 from last year (+|-) leap days + days in current year |
|
41 | + } |
|
42 | 42 | |
43 | 43 | public static function days_diff_in_parts($amount_of_days) |
44 | - { |
|
44 | + { |
|
45 | 45 | $date_diff = []; |
46 | 46 | |
47 | 47 | $previous_part = 'd'; |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | return $date_diff; |
66 | - } |
|
66 | + } |
|
67 | 67 | |
68 | 68 | public static function first_date($year, $month, $format=null) |
69 | 69 | { |
@@ -4,15 +4,15 @@ |
||
4 | 4 | |
5 | 5 | abstract class Base |
6 | 6 | { |
7 | - public static function format($parm='now', $format) |
|
8 | - { |
|
7 | + public static function format($parm='now', $format) |
|
8 | + { |
|
9 | 9 | try |
10 | - { |
|
10 | + { |
|
11 | 11 | $date = new \DateTimeImmutable("$parm"); |
12 | 12 | return $date->format($format); |
13 | 13 | } |
14 | 14 | catch(\Exception $e) |
15 | - { |
|
15 | + { |
|
16 | 16 | return null; |
17 | 17 | } |
18 | 18 | } |