@@ 340-375 (lines=36) @@ | ||
337 | * |
|
338 | * @return object |
|
339 | */ |
|
340 | public function add($value) |
|
341 | { |
|
342 | ||
343 | $this->date_interval_expression = str_replace( |
|
344 | $this->config[ 'date_simple' ], |
|
345 | $this->config[ 'date_interval' ], |
|
346 | $value |
|
347 | ); |
|
348 | ||
349 | $unit = 'P'; |
|
350 | ||
351 | if( strpos($this->date_interval_expression, 'T') ) { |
|
352 | ||
353 | $this->date_interval_expression= str_replace( |
|
354 | 'T', |
|
355 | '', |
|
356 | $this->date_interval_expression |
|
357 | ); |
|
358 | ||
359 | $unit = 'PT'; |
|
360 | ||
361 | } |
|
362 | ||
363 | $this->date_interval_expression = str_replace( |
|
364 | ' ', |
|
365 | '', |
|
366 | $unit . $this->date_interval_expression |
|
367 | ); |
|
368 | ||
369 | $this->date_time->add( |
|
370 | new DateInterval($this->date_interval_expression) |
|
371 | ); |
|
372 | ||
373 | return $this; |
|
374 | ||
375 | } |
|
376 | ||
377 | /** |
|
378 | * Sub date from current date |
|
@@ 384-419 (lines=36) @@ | ||
381 | * |
|
382 | * @return obejct |
|
383 | */ |
|
384 | public function sub($value) |
|
385 | { |
|
386 | ||
387 | $this->date_interval_expression = str_replace( |
|
388 | $this->config[ 'date_simple' ], |
|
389 | $this->config[ 'date_interval' ], |
|
390 | $value |
|
391 | ); |
|
392 | ||
393 | $unit = 'P'; |
|
394 | ||
395 | if( strpos($this->date_interval_expression, 'T') ) { |
|
396 | ||
397 | $this->date_interval_expression= str_replace( |
|
398 | 'T', |
|
399 | '', |
|
400 | $this->date_interval_expression |
|
401 | ); |
|
402 | ||
403 | $unit = 'PT'; |
|
404 | ||
405 | } |
|
406 | ||
407 | $this->date_interval_expression = str_replace( |
|
408 | ' ', |
|
409 | '', |
|
410 | $unit . $this->date_interval_expression |
|
411 | ); |
|
412 | ||
413 | $this->date_time->sub( |
|
414 | new DateInterval($this->date_interval_expression) |
|
415 | ); |
|
416 | ||
417 | return $this; |
|
418 | ||
419 | } |
|
420 | ||
421 | /** |
|
422 | * Check if current year is leap or not |