You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dateparse: date without seconds reads the zone as seconds (wrong timestamp or error) #154
RFC 5322 §3.3 makes seconds optional (time-of-day = hour ":" minute [ ":" second ]), but dateparse always reads the token after the minutes as seconds. When the date has no seconds, the zone is taken as the seconds value:
dateparse("Sat, 14 Dec 1985 11:43:00 +0100")// Ok(503404980) correct
dateparse("Sat, 14 Dec 1985 11:43 +0100")// Ok(503408680) wrong: "+0100" read as 100 seconds, zone dropped
dateparse("Sat, 14 Dec 1985 11:43 -0500")// Err("Invalid second")
dateparse("Sat, 14 Dec 1985 11:43 GMT")// Err("Invalid second")
The first wrong case is silent: any positive zone up to +0255 gives a timestamp that is off by the zone offset (plus up to 255 s). Python's email.utils.parsedate_to_datetime, Go's net/mail.ParseDate and chrono's parse_from_rfc2822 all accept the no-seconds form.
Smaller related gap: FWS can be a tab, but the tokenizer only splits on ' ' and ':', so "Tue,\t12 Aug\t2003\t05:39:03\t-0330" gives Err("Invalid day") (Python accepts it).
Context: I ran generated RFC 5322 Date values (obs zones, 2-digit years, optional day-of-week, optional seconds, mixed whitespace) through several parsers; these were the only gaps in dateparse apart from comments and pre-1970 years, which look intentional.
Possible fix: in the Second state, only accept a 1-2 digit token as seconds; otherwise handle the token as the zone. And split on ' ' | '\t' | '\r' | '\n' | ':'. Happy to send a patch if that helps.
Activity
Accept optional seconds in dateparse
Split date tokens on folding whitespace
Accept optional seconds in dateparse
Split date tokens on folding whitespace
Accept optional seconds in dateparse
Split date tokens on folding whitespace
staktrace commentedon Nov 21, 2026
Fixed, thanks for raising this!