parsedate: clarify time2epoch and add more variations to test 517

Polish the time2epoch function to become a little more readable.

Corrected the military time zones: they were going in the wrong
direction.

Add more curl_getdate() input varations to test 517

Closes #21251
This commit is contained in:
Daniel Stenberg 2026-04-07 11:11:38 +02:00
parent 09f9035045
commit 3536730f33
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
2 changed files with 109 additions and 33 deletions

View file

@ -156,6 +156,80 @@ static CURLcode test_lib517(const char *URL)
#ifndef HAVE_TIME_T_UNSIGNED
{ "Sun, 06 Nov 1968 08:49:37 GMT", -36342623 },
#endif /* !HAVE_TIME_T_UNSIGNED */
#if SIZEOF_TIME_T > 4
{ "2094 Nov 6 08:49:37", 3939871777 },
#endif
{ "01 Jan 2001 8:0:0", 978336000},
{ "01 Jan 2001 8:00:0", 978336000},
/* Out-of-range day-of-month Cases */
{ "29 Feb 2023 12:00:00 GMT", 1677672000},
{ "31 Apr 2024 12:00:00 GMT", 1714564800},
{ "30 Feb 2024 12:00:00 GMT", 1709294400},
{ "01-13-2024", -1},
{ "32 Jan 2024", -1},
{ "31 Jan 2024", 1706659200},
{ "32 Feb 2024", -1},
{ "32 Mar 2024", -1},
{ "32 Apr 2024", -1},
{ "32 May 2024", -1},
{ "32 Jun 2024", -1},
{ "32 Jul 2024", -1},
{ "32 Aug 2024", -1},
{ "32 Sep 2024", -1},
{ "32 Oct 2024", -1},
{ "32 Nov 2024", -1},
{ "32 Dec 2024", -1},
/* Timezone Offsets */
{ "Sun, 06 Nov 1994 08:49:37 +0530", 784091977 },
{ "Sun, 06 Nov 1994 08:49:37 +0545", 784091077 },
{ "06 Nov 1994 08:49:37 Z", 784111777 },
{ "06 Nov 1994 08:49:37 A", 784108177 },
{ "06 Nov 1994 08:49:37 B", 784104577 },
{ "06 Nov 1994 08:49:37 C", 784100977 },
{ "06 Nov 1994 08:49:37 D", 784097377 },
{ "06 Nov 1994 08:49:37 E", 784093777 },
{ "06 Nov 1994 08:49:37 F", 784090177 },
{ "06 Nov 1994 08:49:37 G", 784086577 },
{ "06 Nov 1994 08:49:37 H", 784082977 },
{ "06 Nov 1994 08:49:37 I", 784079377 },
{ "06 Nov 1994 08:49:37 J", -1 }, /* not a valid time zone */
{ "06 Nov 1994 08:49:37 K", 784075777 },
{ "06 Nov 1994 08:49:37 L", 784072177 },
{ "06 Nov 1994 08:49:37 M", 784068577 },
{ "06 Nov 1994 08:49:37 N", 784115377 },
{ "06 Nov 1994 08:49:37 O", 784118977 },
{ "06 Nov 1994 08:49:37 P", 784122577 },
{ "06 Nov 1994 08:49:37 Q", 784126177 },
{ "06 Nov 1994 08:49:37 R", 784129777 },
{ "06 Nov 1994 08:49:37 S", 784133377 },
{ "06 Nov 1994 08:49:37 T", 784136977 },
{ "06 Nov 1994 08:49:37 U", 784140577 },
{ "06 Nov 1994 08:49:37 V", 784144177 },
{ "06 Nov 1994 08:49:37 W", 784147777 },
{ "06 Nov 1994 08:49:37 X", 784151377 },
{ "06 Nov 1994 08:49:37 Y", 784154977 },
{ "GMT+05:30", -1 },
{ "GMT-08:00", -1 },
/* ISO 8601 & Variations - not supported */
{ "1994-11-06T08:49:37Z", -1 },
{ "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},
{ "19 Jan 2038 03:14:08 GMT", 2147483648},
{ "01 Jan 69 00:00:00 GMT", 3124224000},
#endif
{ "01 Jan 1500 00:00:00 GMT", -1},
/* Formatting & Malformed Junk */
{ "Sun, 06-Nov/1994 08:49:37", 784111777},
{ "Sun, 06 Nov 1994 08:49:37 GMT", 784111777},
{ " Sun, 06 Nov 1994 08:49:37 GMT ", 784111777},
{ "Date: Sun, 06 Nov 1994 08:49:37 GMT", -1},
/* wrong day name is ignored */
{ "Monday, 06 Nov 1994 08:49:37 GMT", 784111777},
{ NULL, 0 }
};