1010 ****/  
1111
1212#include  " stdafx.h" 
13+ 
1314#include  < stdint.h> 
1415#include  < string> 
1516
@@ -81,6 +82,10 @@ SUITE(datetime)
8182        auto  dt = utility::datetime::from_string (str, utility::datetime::ISO_8601);
8283        utility::string_t  str2 = dt.to_string (utility::datetime::ISO_8601);
8384        VERIFY_ARE_EQUAL (str2, strExpected);
85+ 
86+         auto  dt_me = utility::datetime::from_string_maximum_error (str, utility::datetime::ISO_8601);
87+         utility::string_t  str3 = dt_me.to_string (utility::datetime::ISO_8601);
88+         VERIFY_ARE_EQUAL (str3, strExpected);
8489    }
8590
8691    void  TestDateTimeRoundtrip (utility::string_t  str) { TestDateTimeRoundtrip (str, str); }
@@ -123,32 +128,18 @@ SUITE(datetime)
123128        TestDateTimeRoundtrip (_XPLATSTR (" 2013-11-19T14:30:59.5Z"  ));
124129    }
125130
126-     TEST (parsing_time_roundtrip_year_1900)
127-     {
128-         TestDateTimeRoundtrip (_XPLATSTR (" 1900-01-01T00:00:00Z"  ));
129-     }
131+     TEST (parsing_time_roundtrip_year_1900) { TestDateTimeRoundtrip (_XPLATSTR (" 1900-01-01T00:00:00Z"  )); }
130132
131-     TEST (parsing_time_roundtrip_year_9999)
132-     {
133-         TestDateTimeRoundtrip (_XPLATSTR (" 9999-12-31T23:59:59Z"  ));
134-     }
133+     TEST (parsing_time_roundtrip_year_9999) { TestDateTimeRoundtrip (_XPLATSTR (" 9999-12-31T23:59:59Z"  )); }
135134
136-     TEST (parsing_time_roundtrip_year_2016)
137-     {
138-         TestDateTimeRoundtrip (_XPLATSTR (" 2016-12-31T20:59:59Z"  ));
139-     }
135+     TEST (parsing_time_roundtrip_year_2016) { TestDateTimeRoundtrip (_XPLATSTR (" 2016-12-31T20:59:59Z"  )); }
140136
141-     TEST (parsing_time_roundtrip_year_2020)
142-     {
143-         TestDateTimeRoundtrip (_XPLATSTR (" 2020-12-31T20:59:59Z"  ));
144-     }
137+     TEST (parsing_time_roundtrip_year_2020) { TestDateTimeRoundtrip (_XPLATSTR (" 2020-12-31T20:59:59Z"  )); }
145138
146-     TEST (parsing_time_roundtrip_year_2021)
147-     {
148-         TestDateTimeRoundtrip (_XPLATSTR (" 2021-01-01T20:59:59Z"  ));
149-     }
139+     TEST (parsing_time_roundtrip_year_2021) { TestDateTimeRoundtrip (_XPLATSTR (" 2021-01-01T20:59:59Z"  )); }
150140
151-     TEST (emitting_time_correct_day) {
141+     TEST (emitting_time_correct_day)
142+     {
152143        const  auto  test = utility::datetime () + UINT64_C (132004507640000000 ); //  2019-04-22T23:52:44 is a Monday
153144        const  auto  actual = test.to_string (utility::datetime::RFC_1123);
154145        const  utility::string_t  expected (_XPLATSTR (" Mon"  ));
@@ -296,13 +287,13 @@ SUITE(datetime)
296287            _XPLATSTR (" Thu, 01 Jan 1970 00:00:00 G"  ),
297288            _XPLATSTR (" Thu, 01 Jan 1970 00:00:00 GM"  ),
298289            _XPLATSTR (" Fri, 01 Jan 1970 00:00:00 GMT"  ), //  wrong day
299-             _XPLATSTR (" 01 Jan 1899 00:00:00 GMT"  ), //  year too small
300-             _XPLATSTR (" 01 Xxx 1971 00:00:00 GMT"  ), //  month bad
301-             _XPLATSTR (" 00 Jan 1971 00:00:00 GMT"  ), //  day too small
302-             _XPLATSTR (" 32 Jan 1971 00:00:00 GMT"  ), //  day too big
303-             _XPLATSTR (" 30 Feb 1971 00:00:00 GMT"  ), //  day too big for feb
304-             _XPLATSTR (" 30 Feb 1971 00:00:00 GMT"  ), //  day too big for feb (non-leap year)
305-             _XPLATSTR (" 32 Mar 1971 00:00:00 GMT"  ), //  other months
290+             _XPLATSTR (" 01 Jan 1899 00:00:00 GMT"  ),       //  year too small
291+             _XPLATSTR (" 01 Xxx 1971 00:00:00 GMT"  ),       //  month bad
292+             _XPLATSTR (" 00 Jan 1971 00:00:00 GMT"  ),       //  day too small
293+             _XPLATSTR (" 32 Jan 1971 00:00:00 GMT"  ),       //  day too big
294+             _XPLATSTR (" 30 Feb 1971 00:00:00 GMT"  ),       //  day too big for feb
295+             _XPLATSTR (" 30 Feb 1971 00:00:00 GMT"  ),       //  day too big for feb (non-leap year)
296+             _XPLATSTR (" 32 Mar 1971 00:00:00 GMT"  ),       //  other months
306297            _XPLATSTR (" 31 Apr 1971 00:00:00 GMT"  ),
307298            _XPLATSTR (" 32 May 1971 00:00:00 GMT"  ),
308299            _XPLATSTR (" 31 Jun 1971 00:00:00 GMT"  ),
@@ -317,8 +308,8 @@ SUITE(datetime)
317308            _XPLATSTR (" 01 Jan 1971 00:60:00 GMT"  ), //  minute too big
318309            _XPLATSTR (" 01 Jan 1971 00:00:70 GMT"  ), //  second too big
319310            _XPLATSTR (" 01 Jan 1971 00:00:61 GMT"  ),
320-             _XPLATSTR (" 01 Jan 1899 00:00:00 GMT"  ), //  underflow
321-             _XPLATSTR (" 01 Jan 1969 00:00:00 CEST"  ), //  bad tz
311+             _XPLATSTR (" 01 Jan 1899 00:00:00 GMT"  ),    //  underflow
312+             _XPLATSTR (" 01 Jan 1969 00:00:00 CEST"  ),   //  bad tz
322313            _XPLATSTR (" 14 Jan 2019 23:16:21 G0100"  ), //  bad tzoffsets
323314            _XPLATSTR (" 01 Jan 1970 00:00:00 +2400"  ),
324315            _XPLATSTR (" 01 Jan 1970 00:00:00 -3000"  ),
@@ -332,6 +323,8 @@ SUITE(datetime)
332323        {
333324            auto  dt = utility::datetime::from_string (str, utility::datetime::RFC_1123);
334325            VERIFY_ARE_EQUAL (0 , dt.to_interval ());
326+             auto  dt_me = utility::datetime::from_string_maximum_error (str, utility::datetime::RFC_1123);
327+             VERIFY_ARE_EQUAL (utility::datetime::maximum (), dt_me);
335328        }
336329    }
337330
@@ -484,7 +477,7 @@ SUITE(datetime)
484477            _XPLATSTR (" 1971-01-01T00:60:00Z"  ), //  minute too big
485478            _XPLATSTR (" 1971-01-01T00:00:70Z"  ), //  second too big
486479            _XPLATSTR (" 1971-01-01T00:00:61Z"  ),
487-             _XPLATSTR (" 1899-01-01T00:00:00Z"  ), //  underflow
480+             _XPLATSTR (" 1899-01-01T00:00:00Z"  ),       //  underflow
488481            _XPLATSTR (" 1900-01-01T00:00:00+00:01"  ), //  time zone underflow
489482            //  _XPLATSTR("1970-01-01T00:00:00.Z"), // accepted as invalid timezone above
490483            _XPLATSTR (" 1970-01-01T00:00:00+24:00"  ), //  bad tzoffsets
@@ -499,23 +492,22 @@ SUITE(datetime)
499492        {
500493            auto  dt = utility::datetime::from_string (str, utility::datetime::ISO_8601);
501494            VERIFY_ARE_EQUAL (dt.to_interval (), 0 );
495+             auto  dt_me = utility::datetime::from_string_maximum_error (str, utility::datetime::ISO_8601);
496+             VERIFY_ARE_EQUAL (dt_me, utility::datetime::maximum ());
502497        }
503498    }
504499
505-     TEST (can_emit_nt_epoch_zero )
500+     TEST (can_emit_nt_epoch_zero_rfc_1123 )
506501    {
507-         //  ISO 8601
508-         {
509-             auto  result = utility::datetime{}.to_string (utility::datetime::RFC_1123);
510-             VERIFY_ARE_EQUAL (_XPLATSTR (" Mon, 01 Jan 1601 00:00:00 GMT"  ), result);
511-         }
512-         //  ISO 8601
513-         {
514-             auto  result = utility::datetime{}.to_string (utility::datetime::ISO_8601);
515-             VERIFY_ARE_EQUAL (_XPLATSTR (" 1601-01-01T00:00:00Z"  ), result);
516-         }
502+         auto  result = utility::datetime {}.to_string (utility::datetime::RFC_1123);
503+         VERIFY_ARE_EQUAL (_XPLATSTR (" Mon, 01 Jan 1601 00:00:00 GMT"  ), result);
517504    }
518505
506+     TEST (can_emit_nt_epoch_zero_iso_8601)
507+     {
508+         auto  result = utility::datetime {}.to_string (utility::datetime::ISO_8601);
509+         VERIFY_ARE_EQUAL (_XPLATSTR (" 1601-01-01T00:00:00Z"  ), result);
510+     }
519511} //  SUITE(datetime)
520512
521513} //  namespace utils_tests
0 commit comments