#date-time #time #date #parser #web

html-datetime-local

A Rust library for parsing local date and time strings based on the WHATWG HTML Living Standard. This may be helpful for server-side code that deals with values from input type=datetime-local

1 unstable release

0.1.0 Dec 18, 2023

#378 in Date and time

MIT license

18KB
315 lines

html-datetime-local

html-datetime-local

GitHub license GitHub Workflow Status Crates.io Crates.io (latest)

Overview

html-datetime-local is a Rust library for parsing local date and time strings based on the WHATWG HTML Living Standard.

This may be helpful for server-side code that deals with values from <input type="datetime-local" />.

Usage

Add this to your Cargo.toml:

[dependencies]
html-datetime-local = "0.1"

Then, in your Rust code:

use html_datetime_local::Datetime;
use std::str::FromStr;

let input = "2023-12-31T23:59:59";
match Datetime::from_str(input) {
    Ok(datetime) => println!("Parsed datetime: {:?}", datetime),
    Err(err) => eprintln!("Error parsing datetime: {}", err),
}

Contributing

Pull requests and bug reports are welcome! If you have any questions or suggestions, feel free to open an issue.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Special thanks to ChatGPT, an AI language model by OpenAI, for providing invaluable assistance during the development of this project. ChatGPT helped with code suggestions, problem-solving, and provided guidance throughout the development process.

License: MIT

Dependencies

~0.5–1MB
~22K SLoC