@@ -133,75 +133,77 @@ SUITE(datetime)
133133
134134 TEST (parsing_time_rfc1123_accepts_each_day)
135135 {
136- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 00:00:00 GMT" ), (time_t ) 0 );
137- TestRfc1123IsTimeT (_XPLATSTR (" Fri, 02 Jan 1970 00:00:00 GMT" ), (time_t ) 86400 * 1 );
138- TestRfc1123IsTimeT (_XPLATSTR (" Sat, 03 Jan 1970 00:00:00 GMT" ), (time_t ) 86400 * 2 );
139- TestRfc1123IsTimeT (_XPLATSTR (" Sun, 04 Jan 1970 00:00:00 GMT" ), (time_t ) 86400 * 3 );
140- TestRfc1123IsTimeT (_XPLATSTR (" Mon, 05 Jan 1970 00:00:00 GMT" ), (time_t ) 86400 * 4 );
141- TestRfc1123IsTimeT (_XPLATSTR (" Tue, 06 Jan 1970 00:00:00 GMT" ), (time_t ) 86400 * 5 );
142- TestRfc1123IsTimeT (_XPLATSTR (" Wed, 07 Jan 1970 00:00:00 GMT" ), (time_t ) 86400 * 6 );
136+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 00:00:00 GMT" ), (time_t )0 );
137+ TestRfc1123IsTimeT (_XPLATSTR (" Fri, 02 Jan 1970 00:00:00 GMT" ), (time_t )86400 * 1 );
138+ TestRfc1123IsTimeT (_XPLATSTR (" Sat, 03 Jan 1970 00:00:00 GMT" ), (time_t )86400 * 2 );
139+ TestRfc1123IsTimeT (_XPLATSTR (" Sun, 04 Jan 1970 00:00:00 GMT" ), (time_t )86400 * 3 );
140+ TestRfc1123IsTimeT (_XPLATSTR (" Mon, 05 Jan 1970 00:00:00 GMT" ), (time_t )86400 * 4 );
141+ TestRfc1123IsTimeT (_XPLATSTR (" Tue, 06 Jan 1970 00:00:00 GMT" ), (time_t )86400 * 5 );
142+ TestRfc1123IsTimeT (_XPLATSTR (" Wed, 07 Jan 1970 00:00:00 GMT" ), (time_t )86400 * 6 );
143143 }
144144
145145 TEST (parsing_time_rfc1123_boundary_cases)
146146 {
147- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 00:00:00 GMT" ), (time_t ) 0 );
148- TestRfc1123IsTimeT (_XPLATSTR (" 19 Jan 2038 03:14:06 GMT" ), (time_t ) INT_MAX - 1 );
149- #ifndef _USE_32BIT_TIME_T
150- TestRfc1123IsTimeT (_XPLATSTR (" 19 Jan 2038 03:13:07 -0001" ), (time_t ) INT_MAX);
151- TestRfc1123IsTimeT (_XPLATSTR (" 19 Jan 2038 03:14:07 -0000" ), (time_t ) INT_MAX);
152- #endif // _USE_32BIT_TIME_T
153- TestRfc1123IsTimeT (_XPLATSTR (" 14 Jan 2019 23:16:21 +0000" ), (time_t ) 1547507781 );
154- TestRfc1123IsTimeT (_XPLATSTR (" 14 Jan 2019 23:16:21 -0001" ), (time_t ) 1547507841 );
155- TestRfc1123IsTimeT (_XPLATSTR (" 14 Jan 2019 23:16:21 +0001" ), (time_t ) 1547507721 );
156- TestRfc1123IsTimeT (_XPLATSTR (" 14 Jan 2019 23:16:21 -0100" ), (time_t ) 1547511381 );
157- TestRfc1123IsTimeT (_XPLATSTR (" 14 Jan 2019 23:16:21 +0100" ), (time_t ) 1547504181 );
147+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 00:00:00 GMT" ), (time_t )0 );
148+ TestRfc1123IsTimeT (_XPLATSTR (" 19 Jan 2038 03:14:06 GMT" ), (time_t )INT_MAX - 1 );
149+ if (sizeof (time_t ) == 8 )
150+ {
151+ TestRfc1123IsTimeT (_XPLATSTR (" 19 Jan 2038 03:13:07 -0001" ), (time_t )INT_MAX);
152+ TestRfc1123IsTimeT (_XPLATSTR (" 19 Jan 2038 03:14:07 -0000" ), (time_t )INT_MAX);
153+ }
154+ TestRfc1123IsTimeT (_XPLATSTR (" 14 Jan 2019 23:16:21 +0000" ), (time_t )1547507781 );
155+ TestRfc1123IsTimeT (_XPLATSTR (" 14 Jan 2019 23:16:21 -0001" ), (time_t )1547507841 );
156+ TestRfc1123IsTimeT (_XPLATSTR (" 14 Jan 2019 23:16:21 +0001" ), (time_t )1547507721 );
157+ TestRfc1123IsTimeT (_XPLATSTR (" 14 Jan 2019 23:16:21 -0100" ), (time_t )1547511381 );
158+ TestRfc1123IsTimeT (_XPLATSTR (" 14 Jan 2019 23:16:21 +0100" ), (time_t )1547504181 );
158159 }
159160
160161 TEST (parsing_time_rfc1123_uses_each_field)
161162 {
162- TestRfc1123IsTimeT (_XPLATSTR (" 02 Jan 1970 00:00:00 GMT" ), (time_t ) 86400 );
163- TestRfc1123IsTimeT (_XPLATSTR (" 12 Jan 1970 00:00:00 GMT" ), (time_t ) 950400 );
164- TestRfc1123IsTimeT (_XPLATSTR (" 01 Feb 1970 00:00:00 GMT" ), (time_t ) 2678400 );
165- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 2000 00:00:00 GMT" ), (time_t ) 946684800 );
166- #ifndef _USE_32BIT_TIME_T
167- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 2100 00:00:00 GMT" ), (time_t ) 4102444800 );
168- #endif // _USE_32BIT_TIME_T
169- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1990 00:00:00 GMT" ), (time_t ) 631152000 );
170- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1971 00:00:00 GMT" ), (time_t ) 31536000 );
171- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 10:00:00 GMT" ), (time_t ) 36000 );
172- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 01:00:00 GMT" ), (time_t ) 3600 );
173- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 00:10:00 GMT" ), (time_t ) 600 );
174- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 00:01:00 GMT" ), (time_t ) 60 );
175- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 00:00:10 GMT" ), (time_t ) 10 );
176- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 00:00:01 GMT" ), (time_t ) 1 );
177- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 10:00:00 GMT" ), (time_t ) 36000 );
178- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 02:00:00 PST" ), (time_t ) 36000 );
179- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 03:00:00 PDT" ), (time_t ) 36000 );
180- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 03:00:00 MST" ), (time_t ) 36000 );
181- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 04:00:00 MDT" ), (time_t ) 36000 );
182- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 04:00:00 CST" ), (time_t ) 36000 );
183- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 05:00:00 CDT" ), (time_t ) 36000 );
184- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 05:00:00 EST" ), (time_t ) 36000 );
185- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 06:00:00 EDT" ), (time_t ) 36000 );
186- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 06:00:00 -0400" ), (time_t ) 36000 );
187- TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 05:59:00 -0401" ), (time_t ) 36000 );
163+ TestRfc1123IsTimeT (_XPLATSTR (" 02 Jan 1970 00:00:00 GMT" ), (time_t )86400 );
164+ TestRfc1123IsTimeT (_XPLATSTR (" 12 Jan 1970 00:00:00 GMT" ), (time_t )950400 );
165+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Feb 1970 00:00:00 GMT" ), (time_t )2678400 );
166+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 2000 00:00:00 GMT" ), (time_t )946684800 );
167+ if (sizeof (time_t ) == 8 )
168+ {
169+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 2100 00:00:00 GMT" ), (time_t )4102444800 );
170+ }
171+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1990 00:00:00 GMT" ), (time_t )631152000 );
172+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1971 00:00:00 GMT" ), (time_t )31536000 );
173+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 10:00:00 GMT" ), (time_t )36000 );
174+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 01:00:00 GMT" ), (time_t )3600 );
175+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 00:10:00 GMT" ), (time_t )600 );
176+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 00:01:00 GMT" ), (time_t )60 );
177+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 00:00:10 GMT" ), (time_t )10 );
178+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 00:00:01 GMT" ), (time_t )1 );
179+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 10:00:00 GMT" ), (time_t )36000 );
180+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 02:00:00 PST" ), (time_t )36000 );
181+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 03:00:00 PDT" ), (time_t )36000 );
182+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 03:00:00 MST" ), (time_t )36000 );
183+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 04:00:00 MDT" ), (time_t )36000 );
184+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 04:00:00 CST" ), (time_t )36000 );
185+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 05:00:00 CDT" ), (time_t )36000 );
186+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 05:00:00 EST" ), (time_t )36000 );
187+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 06:00:00 EDT" ), (time_t )36000 );
188+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 06:00:00 -0400" ), (time_t )36000 );
189+ TestRfc1123IsTimeT (_XPLATSTR (" 01 Jan 1970 05:59:00 -0401" ), (time_t )36000 );
188190 }
189191
190192 TEST (parsing_time_rfc1123_max_days)
191193 {
192- TestRfc1123IsTimeT (_XPLATSTR (" 31 Jan 1970 00:00:00 GMT" ), (time_t ) 2592000 );
193- TestRfc1123IsTimeT (_XPLATSTR (" 28 Feb 2019 00:00:00 GMT" ), (time_t ) 1551312000 ); // non leap year allows feb 28
194- TestRfc1123IsTimeT (_XPLATSTR (" 29 Feb 2020 00:00:00 GMT" ), (time_t ) 1582934400 ); // leap year allows feb 29
195- TestRfc1123IsTimeT (_XPLATSTR (" 31 Mar 1970 00:00:00 GMT" ), (time_t ) 7689600 );
196- TestRfc1123IsTimeT (_XPLATSTR (" 30 Apr 1970 00:00:00 GMT" ), (time_t ) 10281600 );
197- TestRfc1123IsTimeT (_XPLATSTR (" 31 May 1970 00:00:00 GMT" ), (time_t ) 12960000 );
198- TestRfc1123IsTimeT (_XPLATSTR (" 30 Jun 1970 00:00:00 GMT" ), (time_t ) 15552000 );
199- TestRfc1123IsTimeT (_XPLATSTR (" 31 Jul 1970 00:00:00 GMT" ), (time_t ) 18230400 );
200- TestRfc1123IsTimeT (_XPLATSTR (" 31 Aug 1970 00:00:00 GMT" ), (time_t ) 20908800 );
201- TestRfc1123IsTimeT (_XPLATSTR (" 30 Sep 1970 00:00:00 GMT" ), (time_t ) 23500800 );
202- TestRfc1123IsTimeT (_XPLATSTR (" 31 Oct 1970 00:00:00 GMT" ), (time_t ) 26179200 );
203- TestRfc1123IsTimeT (_XPLATSTR (" 30 Nov 1970 00:00:00 GMT" ), (time_t ) 28771200 );
204- TestRfc1123IsTimeT (_XPLATSTR (" 31 Dec 1970 00:00:00 GMT" ), (time_t ) 31449600 );
194+ TestRfc1123IsTimeT (_XPLATSTR (" 31 Jan 1970 00:00:00 GMT" ), (time_t )2592000 );
195+ TestRfc1123IsTimeT (_XPLATSTR (" 28 Feb 2019 00:00:00 GMT" ), (time_t )1551312000 ); // non leap year allows feb 28
196+ TestRfc1123IsTimeT (_XPLATSTR (" 29 Feb 2020 00:00:00 GMT" ), (time_t )1582934400 ); // leap year allows feb 29
197+ TestRfc1123IsTimeT (_XPLATSTR (" 31 Mar 1970 00:00:00 GMT" ), (time_t )7689600 );
198+ TestRfc1123IsTimeT (_XPLATSTR (" 30 Apr 1970 00:00:00 GMT" ), (time_t )10281600 );
199+ TestRfc1123IsTimeT (_XPLATSTR (" 31 May 1970 00:00:00 GMT" ), (time_t )12960000 );
200+ TestRfc1123IsTimeT (_XPLATSTR (" 30 Jun 1970 00:00:00 GMT" ), (time_t )15552000 );
201+ TestRfc1123IsTimeT (_XPLATSTR (" 31 Jul 1970 00:00:00 GMT" ), (time_t )18230400 );
202+ TestRfc1123IsTimeT (_XPLATSTR (" 31 Aug 1970 00:00:00 GMT" ), (time_t )20908800 );
203+ TestRfc1123IsTimeT (_XPLATSTR (" 30 Sep 1970 00:00:00 GMT" ), (time_t )23500800 );
204+ TestRfc1123IsTimeT (_XPLATSTR (" 31 Oct 1970 00:00:00 GMT" ), (time_t )26179200 );
205+ TestRfc1123IsTimeT (_XPLATSTR (" 30 Nov 1970 00:00:00 GMT" ), (time_t )28771200 );
206+ TestRfc1123IsTimeT (_XPLATSTR (" 31 Dec 1970 00:00:00 GMT" ), (time_t )31449600 );
205207 }
206208
207209 TEST (parsing_time_rfc1123_invalid_cases)
@@ -266,7 +268,7 @@ SUITE(datetime)
266268 _XPLATSTR (" Thu, 01 Jan 1970 00:00:00 G" ),
267269 _XPLATSTR (" Thu, 01 Jan 1970 00:00:00 GM" ),
268270 _XPLATSTR (" Fri, 01 Jan 1970 00:00:00 GMT" ), // wrong day
269- _XPLATSTR (" 01 Jan 4970 00:00:00 GMT" ), // year too big
271+ _XPLATSTR (" 01 Jan 4970 00:00:00 GMT" ), // year too big
270272 _XPLATSTR (" 01 Jan 3001 00:00:00 GMT" ),
271273 _XPLATSTR (" 01 Xxx 1971 00:00:00 GMT" ), // month bad
272274 _XPLATSTR (" 00 Jan 1971 00:00:00 GMT" ), // day too small
@@ -288,8 +290,8 @@ SUITE(datetime)
288290 _XPLATSTR (" 01 Jan 1971 00:60:00 GMT" ), // minute too big
289291 _XPLATSTR (" 01 Jan 1971 00:00:70 GMT" ), // second too big
290292 _XPLATSTR (" 01 Jan 1971 00:00:61 GMT" ),
291- _XPLATSTR (" 01 Jan 1969 00:00:00 GMT" ), // underflow
292- _XPLATSTR (" 01 Jan 1969 00:00:00 CEST" ), // bad tz
293+ _XPLATSTR (" 01 Jan 1969 00:00:00 GMT" ), // underflow
294+ _XPLATSTR (" 01 Jan 1969 00:00:00 CEST" ), // bad tz
293295 _XPLATSTR (" 01 Jan 1970 00:00:00 +2400" ), // bad tzoffsets
294296 _XPLATSTR (" 01 Jan 1970 00:00:00 -3000" ),
295297 _XPLATSTR (" 01 Jan 1970 00:00:00 +2160" ),
@@ -309,11 +311,12 @@ SUITE(datetime)
309311 // boundary cases:
310312 TestDateTimeRoundtrip (_XPLATSTR (" 1970-01-01T00:00:00Z" )); // epoch
311313 TestDateTimeRoundtrip (_XPLATSTR (" 2038-01-19T03:14:06+00:00" ), _XPLATSTR (" 2038-01-19T03:14:06Z" )); // INT_MAX - 1
312- #ifndef _USE_32BIT_TIME_T
313- TestDateTimeRoundtrip (_XPLATSTR (" 2038-01-19T03:13:07-00:01" ),
314- _XPLATSTR (" 2038-01-19T03:14:07Z" )); // INT_MAX after subtacting 1
315- TestDateTimeRoundtrip (_XPLATSTR (" 2038-01-19T03:14:07-00:00" ), _XPLATSTR (" 2038-01-19T03:14:07Z" ));
316- #endif // _USE_32BIT_TIME_T
314+ if (sizeof (time_t ) == 8 )
315+ {
316+ TestDateTimeRoundtrip (_XPLATSTR (" 2038-01-19T03:13:07-00:01" ),
317+ _XPLATSTR (" 2038-01-19T03:14:07Z" )); // INT_MAX after subtacting 1
318+ TestDateTimeRoundtrip (_XPLATSTR (" 2038-01-19T03:14:07-00:00" ), _XPLATSTR (" 2038-01-19T03:14:07Z" ));
319+ }
317320 }
318321
319322 TEST (parsing_time_iso8601_uses_each_timezone_digit)
@@ -456,11 +459,8 @@ SUITE(datetime)
456459 _XPLATSTR (" 1971-01-01T00:60:00Z" ), // minute too big
457460 _XPLATSTR (" 1971-01-01T00:00:70Z" ), // second too big
458461 _XPLATSTR (" 1971-01-01T00:00:61Z" ),
459- _XPLATSTR (" 1969-01-01T00:00:00Z" ), // underflow
460- #ifdef _USE_32BIT_TIME_T
461- _XPLATSTR (" 3000-01-01T00:00:01Z" ), // overflow
462- #endif
463- _XPLATSTR (" 3001-01-01T00:00:00Z" ),
462+ _XPLATSTR (" 1969-01-01T00:00:00Z" ), // underflow
463+ _XPLATSTR (" 3001-01-01T00:00:00Z" ), // overflow
464464 _XPLATSTR (" 1970-01-01T00:00:00+00:01" ), // time zone underflow
465465 // _XPLATSTR("1970-01-01T00:00:00.Z"), // accepted as invalid timezone above
466466 _XPLATSTR (" 1970-01-01T00:00:00+24:00" ), // bad tzoffsets
0 commit comments