Crates.io | whatwg-datetime |
lib.rs | whatwg-datetime |
version | 0.1.1 |
source | src |
created_at | 2023-05-26 17:18:30.403122 |
updated_at | 2024-11-03 16:03:50.750197 |
description | A Rust crate for parsing the datetime microsyntax, as defined by the WHATWG HTML Standard |
homepage | |
repository | https://github.com/neoncitylights/whatwg-rust |
max_upload_size | |
id | 875179 |
size | 68,835 |
A Rust crate for parsing the datetime microsyntax, as defined by the WHATWG HTML Standard.
cargo add whatwg-datetime
This library currently implements 8 of the 9 datetime formats defined by the WHATWG HTML Standard. The only format not implemented is the duration format, which is tracked in issue #29.
use chrono::{NaiveDate, NaiveDateTime, NaiveTime, TimeZone, Utc};
use whatwg_datetime::parse_global_datetime;
assert_eq!(
parse_global_datetime("2011-11-18T14:54Z"),
Some(Utc.from_utc_datetime(
&NaiveDateTime::new(
NaiveDate::from_ymd_opt(2011, 11, 18).unwrap(),
NaiveTime::from_hms_opt(14, 54, 0).unwrap(),
)
))
);
Licensed under either of
LICENSE-APACHE
or http://www.apache.org/licenses/LICENSE-2.0)LICENSE-MIT
or http://opensource.org/licenses/MIT)at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.