@@ -812,6 +812,22 @@ public function testCanAddMonthsOverYearBoundary(): void
812812 $ this ->assertSame ('2018-02-10 13:20:33 ' , $ newTime ->toDateTimeString ());
813813 }
814814
815+ public function testCanAddCalendarMonths (): void
816+ {
817+ $ time = Time::parse ('January 31, 2017 13:20:33 ' , 'America/Chicago ' );
818+ $ newTime = $ time ->addCalendarMonths (1 );
819+ $ this ->assertSame ('2017-01-31 13:20:33 ' , $ time ->toDateTimeString ());
820+ $ this ->assertSame ('2017-02-28 13:20:33 ' , $ newTime ->toDateTimeString ());
821+ }
822+
823+ public function testCanAddCalendarMonthsOverYearBoundary (): void
824+ {
825+ $ time = Time::parse ('January 31, 2017 13:20:33 ' , 'America/Chicago ' );
826+ $ newTime = $ time ->addCalendarMonths (13 );
827+ $ this ->assertSame ('2017-01-31 13:20:33 ' , $ time ->toDateTimeString ());
828+ $ this ->assertSame ('2018-02-28 13:20:33 ' , $ newTime ->toDateTimeString ());
829+ }
830+
815831 public function testCanAddYears (): void
816832 {
817833 $ time = Time::parse ('January 10, 2017 13:20:33 ' , 'America/Chicago ' );
@@ -860,6 +876,22 @@ public function testCanSubtractMonths(): void
860876 $ this ->assertSame ('2016-10-10 13:20:33 ' , $ newTime ->toDateTimeString ());
861877 }
862878
879+ public function testCanSubtractCalendarMonths (): void
880+ {
881+ $ time = Time::parse ('March 31, 2017 13:20:33 ' , 'America/Chicago ' );
882+ $ newTime = $ time ->subCalendarMonths (1 );
883+ $ this ->assertSame ('2017-03-31 13:20:33 ' , $ time ->toDateTimeString ());
884+ $ this ->assertSame ('2017-02-28 13:20:33 ' , $ newTime ->toDateTimeString ());
885+ }
886+
887+ public function testCanSubtractCalendarMonthsOverYearBoundary (): void
888+ {
889+ $ time = Time::parse ('March 31, 2017 13:20:33 ' , 'America/Chicago ' );
890+ $ newTime = $ time ->subCalendarMonths (13 );
891+ $ this ->assertSame ('2017-03-31 13:20:33 ' , $ time ->toDateTimeString ());
892+ $ this ->assertSame ('2016-02-29 13:20:33 ' , $ newTime ->toDateTimeString ());
893+ }
894+
863895 public function testCanSubtractYears (): void
864896 {
865897 $ time = Time::parse ('January 10, 2017 13:20:33 ' , 'America/Chicago ' );
0 commit comments