@@ 410-445 (lines=36) @@ | ||
407 | * |
|
408 | * @return object |
|
409 | */ |
|
410 | public function add($value) |
|
411 | { |
|
412 | ||
413 | $this->date_interval_expression = str_replace( |
|
414 | $this->config['date_simple'], |
|
415 | $this->config['date_interval'], |
|
416 | $value |
|
417 | ); |
|
418 | ||
419 | $unit = 'P'; |
|
420 | ||
421 | if (strpos($this->date_interval_expression, 'T')) { |
|
422 | $this->date_interval_expression = str_replace( |
|
423 | 'T', |
|
424 | '', |
|
425 | $this->date_interval_expression |
|
426 | ); |
|
427 | ||
428 | $unit = 'PT'; |
|
429 | } |
|
430 | ||
431 | $this->date_interval_expression = str_replace( |
|
432 | ' ', |
|
433 | '', |
|
434 | $unit.$this->date_interval_expression |
|
435 | ); |
|
436 | ||
437 | $this->date_time->add( |
|
438 | new DateInterval($this->date_interval_expression) |
|
439 | ); |
|
440 | ||
441 | $this->gregorian_DayofWeek = $this->date_time->format('w'); |
|
442 | ||
443 | return $this; |
|
444 | ||
445 | } |
|
446 | ||
447 | /** |
|
448 | * Sub date from current date |
|
@@ 454-489 (lines=36) @@ | ||
451 | * |
|
452 | * @return obejct |
|
453 | */ |
|
454 | public function sub($value) |
|
455 | { |
|
456 | ||
457 | $this->date_interval_expression = str_replace( |
|
458 | $this->config['date_simple'], |
|
459 | $this->config['date_interval'], |
|
460 | $value |
|
461 | ); |
|
462 | ||
463 | $unit = 'P'; |
|
464 | ||
465 | if (strpos($this->date_interval_expression, 'T')) { |
|
466 | $this->date_interval_expression = str_replace( |
|
467 | 'T', |
|
468 | '', |
|
469 | $this->date_interval_expression |
|
470 | ); |
|
471 | ||
472 | $unit = 'PT'; |
|
473 | } |
|
474 | ||
475 | $this->date_interval_expression = str_replace( |
|
476 | ' ', |
|
477 | '', |
|
478 | $unit.$this->date_interval_expression |
|
479 | ); |
|
480 | ||
481 | $this->date_time->sub( |
|
482 | new DateInterval($this->date_interval_expression) |
|
483 | ); |
|
484 | ||
485 | $this->gregorian_DayofWeek = $this->date_time->format('w'); |
|
486 | ||
487 | return $this; |
|
488 | ||
489 | } |
|
490 | ||
491 | /** |
|
492 | * Check if current year is leap or not |