Skip to content

Commit

Permalink
Merge pull request #22 from opencafe/feature/fix-sub-date
Browse files Browse the repository at this point in the history
Fix jalali day of the week return problem
  • Loading branch information
shahrokhniakan authored Sep 1, 2017
2 parents 66c4e0c + cbe5b85 commit 523245f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Datium.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ public function __construct()
$this->gregorian_DayofWeek = $this->date_time->format('w');

$this->convert_calendar = new Convert();

}

/**
Expand Down Expand Up @@ -477,6 +476,8 @@ public function sub($value)
new DateInterval($this->date_interval_expression)
);

$this->gregorian_DayofWeek = $this->date_time->format('w');

return $this;

}
Expand Down Expand Up @@ -590,7 +591,7 @@ public function timestamp()
public function get($format = 'Y-m-d H:i:s')
{

if( $format === 'timestamp' ) {
if ($format === 'timestamp') {

return $this->timestamp();

Expand Down
8 changes: 8 additions & 0 deletions tests/DatiumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,12 @@ public function testGregorianCalendar()
$this->assertEquals('Saturday 25th June 2016 12:00:00 PM', $gregorian);

}

public function testJalaliSubDateTime()
{
$jalali = Datium::create(2017, 9, 1, 12, 0, 0)->sub('1 day')->to('jalali')
->get('l jS F Y h:i:s');

$this->assertEquals("Panjshanbe 9th Shahrivar 1396 12:00:00", $jalali);
}
}

0 comments on commit 523245f

Please sign in to comment.