[][src]Crate diligent_date_parser

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,
);

Re-exports

pub use chrono;

Structs

DateTime

ISO 8601 combined date and time with time zone.

FixedOffset

The time zone with fixed offset, from UTC-23:59:59 to UTC+23:59:59.

Functions

parse_date

Parses a string using multiple formats