File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -736,6 +736,12 @@ static compute_year_result compute_year(int64_t secondsSince1900)
736736 int secondsInt = static_cast <int >(secondsLeft - year4 * SecondsIn4Years);
737737
738738 int year1 = secondsInt / SecondsInYear;
739+ if (year1 == 4 )
740+ {
741+ // this is the last day in a leap year
742+ year1 = 3 ;
743+ }
744+
739745 secondsInt -= year1 * SecondsInYear;
740746
741747 // shift back to 1900 base from 1601:
Original file line number Diff line number Diff line change @@ -133,6 +133,21 @@ SUITE(datetime)
133133 TestDateTimeRoundtrip (_XPLATSTR (" 9999-12-31T23:59:59Z" ));
134134 }
135135
136+ TEST (parsing_time_roundtrip_year_2016)
137+ {
138+ TestDateTimeRoundtrip (_XPLATSTR (" 2016-12-31T20:59:59Z" ));
139+ }
140+
141+ TEST (parsing_time_roundtrip_year_2020)
142+ {
143+ TestDateTimeRoundtrip (_XPLATSTR (" 2020-12-31T20:59:59Z" ));
144+ }
145+
146+ TEST (parsing_time_roundtrip_year_2021)
147+ {
148+ TestDateTimeRoundtrip (_XPLATSTR (" 2021-01-01T20:59:59Z" ));
149+ }
150+
136151 TEST (emitting_time_correct_day) {
137152 const auto test = utility::datetime () + UINT64_C (132004507640000000 ); // 2019-04-22T23:52:44 is a Monday
138153 const auto actual = test.to_string (utility::datetime::RFC_1123);
You can’t perform that action at this time.
0 commit comments