Skip to content

Commit a729c4b

Browse files
committed
fix: Don't panic on dates too far in the past when parsing them. (#1485)
1 parent 3a8b9e2 commit a729c4b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

gix-date/src/parse.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ pub(crate) mod function {
3333
}
3434

3535
Ok(if let Ok(val) = Date::strptime(SHORT.0, input) {
36-
let val = val.to_zoned(TimeZone::UTC).expect("date is in range");
36+
let val = val
37+
.to_zoned(TimeZone::UTC)
38+
.map_err(|_| Error::InvalidDateString { input: input.into() })?;
3739
Time::new(val.timestamp().as_second(), val.offset().seconds())
3840
} else if let Ok(val) = rfc2822_relaxed(input) {
3941
Time::new(val.timestamp().as_second(), val.offset().seconds())

0 commit comments

Comments
 (0)