datetime_parse

Crates.iodatetime_parse
lib.rsdatetime_parse
version0.0.1-beta.11
sourcesrc
created_at2021-05-24 04:44:21.495037
updated_at2023-08-17 07:20:20.39378
descriptionparse various formats of date time strings to rfc3339
homepage
repositoryhttps://github.com/marirs/marirs/datetime-parse-rs
max_upload_size
id401297
size34,862
SG (marirs)

documentation

README

Date Time parser

Crates.io Travis (.org) branch GitHub

Parse various different date/time formats to a standard RFC 3339 format as chrono DateTime FixedOffset.

Note

  • If date/time does NOT have year; current year is added
  • if date/time does NOT have time-zone info; Local time-zone info is added

Some example dates are seen here!

Usage

[dependencies]
datetime_parser = "0.0.1-beta.10"

and

use datetime_parse::DateTimeFixedOffset;

fn main() {
    let date_str = "Mon, 6 Jul 1970 15:30:00 PDT";
    let result = date_str.parse::<DateTimeFixedOffset>();
    assert!(result.is_ok());
    match result {
        Ok(parsed) => println!("{} => {:?}", date_str, parsed.0),
        Err(e) => println!("Error: {}", e)
    }
}

Running the example

cargo run --example parse

Requirements

  • Rust 1.51+

Contribution

Feel free to add more formats that you see, which is not present in the library.


License: MIT

Commit count: 0

cargo fmt