@@ 391-426 (lines=36) @@ | ||
388 | * |
|
389 | * @return object |
|
390 | */ |
|
391 | public function add($value) |
|
392 | { |
|
393 | ||
394 | $this->date_interval_expression = str_replace( |
|
395 | $this->config[ 'date_simple' ], |
|
396 | $this->config[ 'date_interval' ], |
|
397 | $value |
|
398 | ); |
|
399 | ||
400 | $unit = 'P'; |
|
401 | ||
402 | if (strpos($this->date_interval_expression, 'T')) { |
|
403 | $this->date_interval_expression= str_replace( |
|
404 | 'T', |
|
405 | '', |
|
406 | $this->date_interval_expression |
|
407 | ); |
|
408 | ||
409 | $unit = 'PT'; |
|
410 | } |
|
411 | ||
412 | $this->date_interval_expression = str_replace( |
|
413 | ' ', |
|
414 | '', |
|
415 | $unit . $this->date_interval_expression |
|
416 | ); |
|
417 | ||
418 | $this->date_time->add( |
|
419 | new DateInterval($this->date_interval_expression) |
|
420 | ); |
|
421 | ||
422 | return $this; |
|
423 | ||
424 | } |
|
425 | ||
426 | /** |
|
427 | * Sub date from current date |
|
428 | * |
|
429 | * @param string $value How much date should increase from current date |
|
@@ 433-468 (lines=36) @@ | ||
430 | * |
|
431 | * @return obejct |
|
432 | */ |
|
433 | public function sub($value) |
|
434 | { |
|
435 | ||
436 | $this->date_interval_expression = str_replace( |
|
437 | $this->config[ 'date_simple' ], |
|
438 | $this->config[ 'date_interval' ], |
|
439 | $value |
|
440 | ); |
|
441 | ||
442 | $unit = 'P'; |
|
443 | ||
444 | if (strpos($this->date_interval_expression, 'T')) { |
|
445 | $this->date_interval_expression= str_replace( |
|
446 | 'T', |
|
447 | '', |
|
448 | $this->date_interval_expression |
|
449 | ); |
|
450 | ||
451 | $unit = 'PT'; |
|
452 | } |
|
453 | ||
454 | $this->date_interval_expression = str_replace( |
|
455 | ' ', |
|
456 | '', |
|
457 | $unit . $this->date_interval_expression |
|
458 | ); |
|
459 | ||
460 | $this->date_time->sub( |
|
461 | new DateInterval($this->date_interval_expression) |
|
462 | ); |
|
463 | ||
464 | return $this; |
|
465 | ||
466 | } |
|
467 | ||
468 | /** |
|
469 | * Check if current year is leap or not |
|
470 | * |
|
471 | * @param string $type Name of the calendar to caculate leap year |