@@ -6,7 +6,7 @@ |
||
6 | 6 | { |
7 | 7 | const FORMAT = 'Y-m-d H:i:s'; |
8 | 8 | |
9 | - public static function format($parm=null, $format=null) |
|
9 | + public static function format($parm = null, $format = null) |
|
10 | 10 | { |
11 | 11 | return parent::format($parm, $format ?? self::FORMAT); |
12 | 12 | } |
@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | const MONTHES_IN_A_YEAR = 12; |
13 | 13 | |
14 | 14 | |
15 | - public static function format($parm=null, $format=null) |
|
15 | + public static function format($parm = null, $format = null) |
|
16 | 16 | { |
17 | 17 | $format = $format ?? self::FORMAT; |
18 | 18 | return parent::format($parm, $format); |
19 | 19 | } |
20 | 20 | |
21 | - public static function today($format=null) |
|
21 | + public static function today($format = null) |
|
22 | 22 | { |
23 | 23 | $format = $format ?? self::FORMAT; |
24 | 24 | return parent::format(null, $format); |
@@ -27,14 +27,14 @@ 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 | - return (is_a($a,$c) && is_a($b,$c)) ? self::days($a) - self::days($b) : false; |
|
30 | + return (is_a($a, $c) && is_a($b, $c)) ? self::days($a) - self::days($b) : false; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public static function days($x, $d = 0) |
34 | 34 | { |
35 | 35 | $lfy = $x->format('Y') - 1; // last full year |
36 | 36 | |
37 | - foreach([4, -100, 400] as $f) // leap year factors |
|
37 | + foreach ([4, -100, 400] as $f) // leap year factors |
|
38 | 38 | $d += ($lfy / $f); |
39 | 39 | |
40 | 40 | return (int)(($lfy * 365.25) + $d + $x->format('z')); // days since 1.1.1001 from last year (+|-) leap days + days in current year |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | |
47 | 47 | $previous_part = 'd'; |
48 | 48 | |
49 | - foreach(['w' => self::DAYS_IN_A_WEEK, 'm' => self::WEEKS_IN_A_MONTH, 'y' => self::MONTHES_IN_A_YEAR] as $part => $limit) |
|
49 | + foreach (['w' => self::DAYS_IN_A_WEEK, 'm' => self::WEEKS_IN_A_MONTH, 'y' => self::MONTHES_IN_A_YEAR] as $part => $limit) |
|
50 | 50 | { |
51 | - if($amount_of_days >= $limit) |
|
51 | + if ($amount_of_days >= $limit) |
|
52 | 52 | { |
53 | 53 | $date_diff[$part] = intval($amount_of_days / $limit); |
54 | 54 | $date_diff[$previous_part] = $amount_of_days % $limit; |
@@ -65,21 +65,21 @@ discard block |
||
65 | 65 | return $date_diff; |
66 | 66 | } |
67 | 67 | |
68 | - public static function first_date($year, $month, $format=null) |
|
68 | + public static function first_date($year, $month, $format = null) |
|
69 | 69 | { |
70 | 70 | $format = $format ?? self::FORMAT; |
71 | 71 | return date_format(new \DateTime("$year-$month-1"), $format); |
72 | 72 | } |
73 | 73 | |
74 | - public static function last_date($year,$month, $format=null) |
|
74 | + public static function last_date($year, $month, $format = null) |
|
75 | 75 | { |
76 | 76 | $format = $format ?? self::FORMAT; |
77 | - return date_format(new \DateTime("$year-$month-".self::last_day($year,$month)), $format); |
|
77 | + return date_format(new \DateTime("$year-$month-".self::last_day($year, $month)), $format); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | public static function last_day($year, $month) |
81 | 81 | { |
82 | - return date_format(new \DateTime("$year-$month-1"),'t'); |
|
82 | + return date_format(new \DateTime("$year-$month-1"), 't'); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 |
@@ -4,14 +4,14 @@ |
||
4 | 4 | |
5 | 5 | abstract class Base |
6 | 6 | { |
7 | - public static function format($parm='now', $format) |
|
7 | + public static function format($parm = 'now', $format) |
|
8 | 8 | { |
9 | 9 | try |
10 | 10 | { |
11 | 11 | $date = new \DateTimeImmutable("$parm"); |
12 | 12 | return $date->format($format); |
13 | 13 | } |
14 | - catch(\Exception $e) |
|
14 | + catch (\Exception $e) |
|
15 | 15 | { |
16 | 16 | return null; |
17 | 17 | } |