Skip to content

Commit

Permalink
Update the Hijri date when the timestamp is changed by using modify
Browse files Browse the repository at this point in the history
method

When the timestamp is changed using any carbon methods to add or
subtract time, the hijri date will be updated as well.
This will close #33
  • Loading branch information
alhoqbani committed Jul 27, 2017
1 parent b941773 commit 0a64d9e
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/ArUtil/Time/ArDateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 183,25 @@ public function arToDateString()
{
return $this->arFormat('Y-m-d');
}

/**

/**
* Update the hijri date when the instance timestamp is changed
* @param string $modify
*
* @return static
*/
public function modify( $modify ) {
$instance = parent::modify( $modify );
list(
$instance->arYear,
$instance->arMonth,
$instance->arDay
) = ( new Date() )->hjConvert( $instance->year, $instance->month, $instance->day );

return $instance;
}

/**
* Set the instance Hijri date for today.
*/
private function setTodayHijriDate()
Expand Down

0 comments on commit 0a64d9e

Please sign in to comment.