diff --git a/src/Datium.php b/src/Datium.php index 6090713..84a9f22 100644 --- a/src/Datium.php +++ b/src/Datium.php @@ -160,7 +160,6 @@ public function __construct() $this->gregorian_DayofWeek = $this->date_time->format('w'); $this->convert_calendar = new Convert(); - } /** @@ -477,6 +476,8 @@ public function sub($value) new DateInterval($this->date_interval_expression) ); + $this->gregorian_DayofWeek = $this->date_time->format('w'); + return $this; } @@ -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(); diff --git a/tests/DatiumTest.php b/tests/DatiumTest.php index 69e2aa6..4a492b4 100644 --- a/tests/DatiumTest.php +++ b/tests/DatiumTest.php @@ -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); + } }