@@ -812,6 +812,22 @@ public function testCanAddMonthsOverYearBoundary(): void
812
812
$ this ->assertSame ('2018-02-10 13:20:33 ' , $ newTime ->toDateTimeString ());
813
813
}
814
814
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
+
815
831
public function testCanAddYears (): void
816
832
{
817
833
$ time = Time::parse ('January 10, 2017 13:20:33 ' , 'America/Chicago ' );
@@ -860,6 +876,22 @@ public function testCanSubtractMonths(): void
860
876
$ this ->assertSame ('2016-10-10 13:20:33 ' , $ newTime ->toDateTimeString ());
861
877
}
862
878
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
+
863
895
public function testCanSubtractYears (): void
864
896
{
865
897
$ time = Time::parse ('January 10, 2017 13:20:33 ' , 'America/Chicago ' );
0 commit comments