@@ -24,26 +24,26 @@ 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 | - { |
|
| 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 | 30 | if(!is_a($a,$c) || !is_a($b,$c)) |
| 31 | 31 | throw new \InvalidArgumentException('ARGUMENT_MUST_HAVE_SAME_TYPE'); |
| 32 | - return self::days($a) - self::days($b); |
|
| 33 | - } |
|
| 32 | + return self::days($a) - self::days($b); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - public static function days($x, $d = 0) |
|
| 36 | - { |
|
| 35 | + public static function days($x, $d = 0) |
|
| 36 | + { |
|
| 37 | 37 | $lfy = $x->format('Y') - 1; // last full year |
| 38 | 38 | |
| 39 | - foreach([4, -100, 400] as $f) // leap year factors |
|
| 40 | - $d += ($lfy / $f); |
|
| 39 | + foreach([4, -100, 400] as $f) // leap year factors |
|
| 40 | + $d += ($lfy / $f); |
|
| 41 | 41 | |
| 42 | - return (int)(($lfy * 365.25) + $d + $x->format('z')); // days since 1.1.1001 from last year (+|-) leap days + days in current year |
|
| 43 | - } |
|
| 42 | + return (int)(($lfy * 365.25) + $d + $x->format('z')); // days since 1.1.1001 from last year (+|-) leap days + days in current year |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | public static function days_diff_in_parts($amount_of_days) |
| 46 | - { |
|
| 46 | + { |
|
| 47 | 47 | $date_diff = []; |
| 48 | 48 | |
| 49 | 49 | $previous_part = 'd'; |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | return $date_diff; |
| 68 | - } |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | 70 | public static function first_date($year, $month, $format=null) |
| 71 | 71 | { |