@@ 176-201 (lines=26) @@ | ||
173 | * |
|
174 | * @param int $timestamp |
|
175 | */ |
|
176 | public function set_earliest_event( $timestamp = 0 ) { |
|
177 | ||
178 | $earliest = intval( $timestamp ); |
|
179 | ||
180 | if ( $earliest === 0 ) { |
|
181 | ||
182 | $start = Carbon::createFromTimestamp( $this->calendar_start, $this->timezone ); |
|
183 | ||
184 | $earliest_date = esc_attr( get_post_meta( $this->post_id, '_feed_earliest_event_date', true ) ); |
|
185 | $earliest_range = max( absint( get_post_meta( $this->post_id, '_feed_earliest_event_date_range', true ) ), 1 ); |
|
186 | ||
187 | if ( 'days_before' == $earliest_date ) { |
|
188 | $earliest = $start->subDays( $earliest_range )->getTimestamp(); |
|
189 | } elseif ( 'weeks_before' == $earliest_date ) { |
|
190 | $earliest = $start->subWeeks( $earliest_range )->addDay()->getTimestamp(); |
|
191 | } elseif ( 'months_before' == $earliest_date ) { |
|
192 | $earliest = $start->subMonths( $earliest_range )->addDay()->getTimestamp(); |
|
193 | } elseif ( 'years_before' == $earliest_date ) { |
|
194 | $earliest = $start->subYears( $earliest_range )->addDay()->getTimestamp(); |
|
195 | } else { |
|
196 | $earliest = $start->getTimestamp(); |
|
197 | } |
|
198 | } |
|
199 | ||
200 | $this->time_min = $earliest; |
|
201 | } |
|
202 | ||
203 | /** |
|
204 | * Set latest event. |
|
@@ 210-236 (lines=27) @@ | ||
207 | * |
|
208 | * @param int $timestamp |
|
209 | */ |
|
210 | public function set_latest_event( $timestamp = 0 ) { |
|
211 | ||
212 | $latest = intval( $timestamp ); |
|
213 | ||
214 | if ( $latest === 0 ) { |
|
215 | ||
216 | $start = Carbon::createFromTimestamp( $this->calendar_start, $this->timezone )->endOfDay(); |
|
217 | ||
218 | $latest_date = esc_attr( get_post_meta( $this->post_id, '_feed_latest_event_date', true ) ); |
|
219 | $latest_range = max( absint( get_post_meta( $this->post_id, '_feed_latest_event_date_range', true ) ), 1 ); |
|
220 | ||
221 | if ( 'days_after' == $latest_date ) { |
|
222 | $latest = $start->addDays( $latest_range )->getTimestamp(); |
|
223 | } elseif ( 'weeks_after' == $latest_date ) { |
|
224 | $latest = $start->addWeeks( $latest_range )->subDay()->getTimestamp(); |
|
225 | } elseif ( 'months_after' == $latest_date ) { |
|
226 | $latest = $start->addMonths( $latest_range )->subDay()->getTimestamp(); |
|
227 | } elseif ( 'years_after' == $latest_date ) { |
|
228 | $latest = $start->addYears( $latest_range )->subDay()->getTimestamp(); |
|
229 | } else { |
|
230 | $latest = $start->getTimestamp(); |
|
231 | } |
|
232 | ||
233 | } |
|
234 | ||
235 | $this->time_max = $latest; |
|
236 | } |
|
237 | ||
238 | /** |
|
239 | * Set cache. |