whatwg_datetime/
lib.rs

1/*!
2A Rust crate for parsing the datetime microsyntax, as defined by the WHATWG HTML Standard.
3
4## Install
5
6```shell
7cargo add whatwg-datetime
8```
9
10## Usage
11
12This 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 #23](https://github.com/neoncitylights/whatwg-rust/issues/23).
13
14```rust
15use chrono::{NaiveDate, NaiveDateTime, NaiveTime, TimeZone, Utc};
16use whatwg_datetime::parse_global_datetime;
17
18assert_eq!(
19	parse_global_datetime("2011-11-18T14:54Z"),
20	Some(Utc.from_utc_datetime(
21		&NaiveDateTime::new(
22			NaiveDate::from_ymd_opt(2011, 11, 18).unwrap(),
23			NaiveTime::from_hms_opt(14, 54, 0).unwrap(),
24		)
25	))
26);
27```
28*/
29
30mod components;
31mod utils;
32
33pub use crate::components::*;
34
35pub type ParseStringFn<T> = dyn Fn(&str) -> Option<T>;
36pub type ParseComponentFn<T> = dyn Fn(&str, &mut usize) -> Option<T>;