Skip to content

Commit

Permalink
Bump chrono and reorder attemps accordingly to its new relaxed parser
Browse files Browse the repository at this point in the history
  • Loading branch information
andy128k committed Nov 15, 2024
1 parent 1975e76 commit 54175b9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ repository = "https://github.com/rust-syndication/diligent-date-parser"
documentation = "https://docs.rs/diligent-date-parser/"

[dependencies]
chrono = { version = "0.4", default-features = false }
chrono = { version = "0.4.27", default-features = false }
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ fn utc_date(string: &str, format: &str) -> Option<DateTime<FixedOffset>> {
pub fn parse_date(string: &str) -> Option<DateTime<FixedOffset>> {
let trimmed = string.trim();
None.or_else(|| rfc3339(trimmed))
.or_else(|| cut(trimmed, 20).and_then(rfc3339))
.or_else(|| cut(trimmed, 19).map(|s| suffix(s, "Z")).and_then(rfc3339))
.or_else(|| DateTime::parse_from_str(trimmed, "%Y-%m-%d %H:%M:%S%.3f %z").ok())
.or_else(|| utc_datetime(trimmed, "%Y-%m-%d %H:%M:%S%.3f"))
.or_else(|| cut(trimmed, 20).and_then(rfc3339))
.or_else(|| cut(trimmed, 19).map(|s| suffix(s, "Z")).and_then(rfc3339))
.or_else(|| {
cut(trimmed, 16)
.map(|s| suffix(s, ":00Z"))
Expand Down

0 comments on commit 54175b9

Please sign in to comment.