#date-parser #date-time #date-format #parser #date

diligent-date-parser

Library for parsing datetime in unknown format

6 releases

new 0.1.5 Nov 15, 2024
0.1.4 Dec 29, 2022
0.1.3 Oct 20, 2021
0.1.2 Jul 17, 2020
0.1.0 May 12, 2020

#70 in Date and time

Download history 3387/week @ 2024-07-29 3356/week @ 2024-08-05 3964/week @ 2024-08-12 3303/week @ 2024-08-19 3862/week @ 2024-08-26 3641/week @ 2024-09-02 3301/week @ 2024-09-09 3527/week @ 2024-09-16 3366/week @ 2024-09-23 3255/week @ 2024-09-30 2470/week @ 2024-10-07 3411/week @ 2024-10-14 3556/week @ 2024-10-21 3876/week @ 2024-10-28 3462/week @ 2024-11-04 3990/week @ 2024-11-11

15,085 downloads per month
Used in 37 crates (2 directly)

MIT/Apache

14KB
262 lines

Diligent Date Parser

Crates.io Status

This is a Rust library to parse dates in unknown format. It diligently tries to apply known patterns and returns best found match.


lib.rs:

This is a library to parse dates in unknown format. It diligently tries to apply known patterns and returns best found match.

Examples

use diligent_date_parser::parse_date;
use diligent_date_parser::chrono::prelude::*;
use diligent_date_parser::chrono::offset::FixedOffset;

assert_eq!(
    parse_date("Mon, 2 Jan 2006 15:04:05 MST"),
    Some(FixedOffset::west(7 * 3600).ymd(2006, 1, 2).and_hms(15, 4, 5)),
);
assert_eq!(
    parse_date("Apr 21 2016"),
    Some(Utc.ymd(2016, 4, 21).and_hms(0, 0, 0).into()),
);
assert_eq!(
    parse_date("Sun Dec 24 13:19:25 +0200 2017"),
    Some(Utc.ymd(2017, 12, 24).and_hms(11, 19, 25).into()),
);
assert_eq!(
    parse_date("Yesterday"),
    None,
);

Dependencies

~1MB
~18K SLoC