@@ -151,9 +151,9 @@ |
||
151 | 151 | $dt = new DateTime("now", new DateTimeZone($this->timezone)); |
152 | 152 | $dt2 = new DateTime("now", new DateTimeZone($this->timezone)); |
153 | 153 | $end = $dt ->add(new \DateInterval('P1D')) // add a day, so the end date gets included in the intervals |
154 | - ->add(new \DateInterval('PT2M')); // add two minutes, to be sure we have everything |
|
154 | + ->add(new \DateInterval('PT2M')); // add two minutes, to be sure we have everything |
|
155 | 155 | $start = $dt2->add(new \DateInterval('PT2M')) // add two minutes, to be sure we have everything |
156 | - ->sub(new \DateInterval("P${period}D")); // subtract `$period` number of days |
|
156 | + ->sub(new \DateInterval("P${period}D")); // subtract `$period` number of days |
|
157 | 157 | |
158 | 158 | $periods = new \DatePeriod($start, new \DateInterval('P1D'), $end, \DatePeriod::EXCLUDE_START_DATE); |
159 | 159 | $local_tz = new \DateTimeZone($this->timezone); |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | * @return \DateTime the parsed time or the default value |
37 | 37 | */ |
38 | 38 | public function parse($time, $default = false, string $format = 'Y-m-d') { |
39 | - if(is_string($time)) { |
|
39 | + if (is_string($time)) { |
|
40 | 40 | $dt = DateTime::createFromFormat($format, $time, new DateTimeZone($this->timezone)); |
41 | - if($dt) { |
|
41 | + if ($dt) { |
|
42 | 42 | // for some reason, using createFromFromat adds in the time. The regular DateTime constructor _does not_ do this. We manually zero out the time here to make the DateTime objects match. |
43 | 43 | $dt->setTime(0, 0, 0); |
44 | 44 | $formatted = $dt->format($format); |
45 | - if($formatted === $time && $this->inBounds($dt)) { |
|
45 | + if ($formatted === $time && $this->inBounds($dt)) { |
|
46 | 46 | return $dt; |
47 | 47 | } |
48 | 48 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | $test = strtotime($dt->format('Y-m-d')); |
63 | 63 | $now = strtotime($this->getLocalDate()); |
64 | 64 | |
65 | - if($first <= $test && $test <= $now) { |
|
65 | + if ($first <= $test && $test <= $now) { |
|
66 | 66 | return true; |
67 | 67 | } else { |
68 | 68 | return false; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | public function getLocalTime($timezone = null) { |
89 | - if($timezone === null) |
|
89 | + if ($timezone === null) |
|
90 | 90 | $timezone = $this->timezone; |
91 | 91 | |
92 | 92 | $timestamp = new DateTime("now", new DateTimeZone($timezone)); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | } |
95 | 95 | |
96 | 96 | public function getLocalDate($timezone = null) { |
97 | - if($timezone === null) |
|
97 | + if ($timezone === null) |
|
98 | 98 | $timezone = $this->timezone; |
99 | 99 | |
100 | 100 | return (new DateTime("now", new DateTimeZone($timezone))) |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | public function getUTCBookends($local) { |
110 | 110 | $local = trim($local); |
111 | - if(strpos($local, " ")) { |
|
111 | + if (strpos($local, " ")) { |
|
112 | 112 | return false; |
113 | 113 | } |
114 | 114 | |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | * @return string a date string |
131 | 131 | */ |
132 | 132 | public function validate($date = null) { |
133 | - if(is_null($date)) { |
|
133 | + if (is_null($date)) { |
|
134 | 134 | return $this->getLocalDate(); |
135 | - } else if($dt = $this->parse($date)) { |
|
135 | + } else if ($dt = $this->parse($date)) { |
|
136 | 136 | return $dt->format('Y-m-d'); |
137 | 137 | } else { |
138 | 138 | return $this->getLocalDate(); |
@@ -151,13 +151,13 @@ discard block |
||
151 | 151 | $dt = new DateTime("now", new DateTimeZone($this->timezone)); |
152 | 152 | $dt2 = new DateTime("now", new DateTimeZone($this->timezone)); |
153 | 153 | $end = $dt ->add(new \DateInterval('P1D')) // add a day, so the end date gets included in the intervals |
154 | - ->add(new \DateInterval('PT2M')); // add two minutes, to be sure we have everything |
|
154 | + ->add(new \DateInterval('PT2M')); // add two minutes, to be sure we have everything |
|
155 | 155 | $start = $dt2->add(new \DateInterval('PT2M')) // add two minutes, to be sure we have everything |
156 | 156 | ->sub(new \DateInterval("P${period}D")); // subtract `$period` number of days |
157 | 157 | |
158 | 158 | $periods = new \DatePeriod($start, new \DateInterval('P1D'), $end, \DatePeriod::EXCLUDE_START_DATE); |
159 | 159 | $local_tz = new \DateTimeZone($this->timezone); |
160 | - foreach($periods as $period) { |
|
160 | + foreach ($periods as $period) { |
|
161 | 161 | $period->setTimezone($local_tz); |
162 | 162 | } |
163 | 163 | return $periods; |