parsedate: refactor

- introduce 'struct when' to hold the parser result
- initwhen() initializes a 'struct when'
- datestring() parses strings
- datenum() parses numbers
- datecheck() does some final checks
- tzadjust() adds the time zone offset
- convert math to 64 bit, squeeze into time_t only in the last step,
  mktimet() does the time_t storing

Closes #21394
This commit is contained in:
Daniel Stenberg 2026-04-21 09:19:53 +02:00
parent 5ff7f77310
commit 2e3607034d
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
2 changed files with 223 additions and 203 deletions

View file

@ -127,6 +127,7 @@ static CURLcode test_lib517(const char *URL)
{ "IAintNoDateFool", -1 },
{ "Thu Apr 18 22:50 2007 GMT", 1176936600 },
{ "20110623 12:34:56", 1308832496 },
{ "20110023 12:34:56", -1 },
{ "20110632 12:34:56", -1 },
{ "20110623 56:34:56", -1 },
{ "20111323 12:34:56", -1 },
@ -219,9 +220,8 @@ static CURLcode test_lib517(const char *URL)
{ "1994-11-06 08:49:37.123 GMT", -1 },
{ "19941106T084937Z", -1 },
/* Y2K38 & Historical Boundaries */
#if SIZEOF_TIME_T > 4
/* for 32 bit time_t, we bail on >year 2037 */
{ "19 Jan 2038 03:14:07 GMT", 2147483647 },
#if SIZEOF_TIME_T > 4
{ "19 Jan 2038 03:14:08 GMT", 2147483648 },
{ "01 Jan 69 00:00:00 GMT", 3124224000 },
#endif