File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -354,6 +354,11 @@ public function subDays(int $days = 1): Jalalian
354354 return static ::fromCarbon ($ this ->toCarbon ()->subDays ($ days ));
355355 }
356356
357+ public function subDay (): Jalalian
358+ {
359+ return $ this ->subDays (1 );
360+ }
361+
357362 /**
358363 * @return Carbon
359364 */
@@ -648,16 +653,31 @@ public function getNextWeek(): Jalalian
648653 return $ this ->addDays (7 );
649654 }
650655
656+ public function getLastWeek (): Jalalian
657+ {
658+ return $ this ->subDays (7 );
659+ }
660+
651661 public function addDays (int $ days = 1 ): Jalalian
652662 {
653663 return static ::fromCarbon ($ this ->toCarbon ()->addDays ($ days ));
654664 }
655665
666+ public function addDay (): Jalalian
667+ {
668+ return $ this ->addDays (1 );
669+ }
670+
656671 public function getNextMonth (): Jalalian
657672 {
658673 return $ this ->addMonths (1 );
659674 }
660675
676+ public function getLastMonth (): Jalalian
677+ {
678+ return $ this ->subMonths (1 );
679+ }
680+
661681 public function getWeekOfMonth (): int
662682 {
663683 return floor (($ this ->day + 5 - $ this ->getDayOfWeek ()) / 7 ) + 1 ;
Original file line number Diff line number Diff line change @@ -205,4 +205,28 @@ public function testGetFirstDayOfYear()
205205 $ jDate = new Jalalian (1393 , 9 , 5 );
206206 $ this ->assertEquals ($ jDate ->getFirstDayOfYear ()->format ('Y-m-d ' ), '1393-01-01 ' );
207207 }
208+
209+ public function testAddDay ()
210+ {
211+ $ jDate = new Jalalian (1401 , 6 , 31 );
212+ $ this ->assertEquals ($ jDate ->addDay ()->format ('Y-m-d ' ), '1401-07-01 ' );
213+ }
214+
215+ public function testSubDay ()
216+ {
217+ $ jDate = new Jalalian (1401 , 6 , 1 );
218+ $ this ->assertEquals ($ jDate ->subDay ()->format ('Y-m-d ' ), '1401-05-31 ' );
219+ }
220+
221+ public function testGetLastWeek ()
222+ {
223+ $ jDate = new Jalalian (1401 , 6 , 8 );
224+ $ this ->assertEquals ($ jDate ->getLastWeek ()->format ('Y-m-d ' ), '1401-06-01 ' );
225+ }
226+
227+ public function testGetLastMonth ()
228+ {
229+ $ jDate = new Jalalian (1401 , 6 , 8 );
230+ $ this ->assertEquals ($ jDate ->getLastMonth ()->format ('Y-m-d ' ), '1401-05-08 ' );
231+ }
208232}
You can’t perform that action at this time.
0 commit comments