Skip to content

Commit

Permalink
fix: Don't panic on dates too far in the past when parsing them. (Git…
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron authored and LuaKT committed Aug 20, 2024
1 parent b4126a5 commit fd48466
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gix-date/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ pub(crate) mod function {
}

Ok(if let Ok(val) = Date::strptime(SHORT.0, input) {
let val = val.to_zoned(TimeZone::UTC).expect("date is in range");
let val = val
.to_zoned(TimeZone::UTC)
.map_err(|_| Error::InvalidDateString { input: input.into() })?;
Time::new(val.timestamp().as_second(), val.offset().seconds())
} else if let Ok(val) = rfc2822_relaxed(input) {
Time::new(val.timestamp().as_second(), val.offset().seconds())
Expand Down

0 comments on commit fd48466

Please sign in to comment.