1
0
mirror of https://github.com/bspeice/dtparse synced 2025-07-03 06:45:01 -04:00

2 Commits

Author SHA1 Message Date
081cd7bea0 Release version 2.1.0 2024-08-18 20:43:00 +00:00
c3d6730e9c #45: Fix index issue 2024-08-18 20:42:20 +00:00
3 changed files with 11 additions and 2 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "dtparse" name = "dtparse"
version = "2.0.0" version = "2.0.1"
authors = ["Bradlee Speice <bradlee@speice.io>"] authors = ["Bradlee Speice <bradlee@speice.io>"]
description = "A dateutil-compatible timestamp parser for Rust" description = "A dateutil-compatible timestamp parser for Rust"
repository = "https://github.com/bspeice/dtparse.git" repository = "https://github.com/bspeice/dtparse.git"

View File

@ -1132,7 +1132,9 @@ impl Parser {
} }
if idx + 3 < len_l && &tokens[idx + 3] == sep { if idx + 3 < len_l && &tokens[idx + 3] == sep {
if let Some(value) = info.month_index(&tokens[idx + 4]) { if tokens.len() <= idx + 4 {
return Err(ParseError::UnrecognizedFormat);
} else if let Some(value) = info.month_index(&tokens[idx + 4]) {
ymd.append(value as i32, &tokens[idx + 4], Some(YMDLabel::Month))?; ymd.append(value as i32, &tokens[idx + 4], Some(YMDLabel::Month))?;
} else if let Ok(val) = tokens[idx + 4].parse::<i32>() { } else if let Ok(val) = tokens[idx + 4].parse::<i32>() {
ymd.append(val, &tokens[idx + 4], None)?; ymd.append(val, &tokens[idx + 4], None)?;

View File

@ -97,3 +97,10 @@ fn github_36() {
let parse_result = parse(parse_str); let parse_result = parse(parse_str);
assert!(parse_result.is_err()); assert!(parse_result.is_err());
} }
#[test]
fn github_45() {
assert!(parse("/2018-fifa-").is_err());
assert!(parse("/2009/07/").is_err());
assert!(parse("2021-09-").is_err());
}