#日期时间 #whatwg #HTML #html-datetime

whatwg-datetime

根据WHATWG HTML标准定义的日期时间微语法的Rust包

1 个不稳定版本

0.1.0 2023年5月26日

#2864解析器实现

MIT/Apache

55KB
1K SLoC

whatwg-datetime

License CI Security audit codecov

根据WHATWG HTML标准定义的日期时间微语法的Rust包。

安装

cargo add whatwg-datetime

用法

此库目前实现了WHATWG HTML标准定义的9种日期时间格式中的8种。未实现的是持续时间格式,该格式在问题#29中跟踪。

use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, Utc};
use whatwg_datetime::parse_global_datetime;

assert_eq!(
	parse_global_datetime("2011-11-18T14:54Z"),
	Some(DateTime::<Utc>::from_utc(
		NaiveDateTime::new(
			NaiveDate::from_ymd_opt(2011, 11, 18).unwrap(),
			NaiveTime::from_hms_opt(14, 54, 0).unwrap(),
		),
		Utc,
	))
);

许可证

根据以下其中一种许可证授权:

由您选择。

贡献

除非您明确声明,否则任何有意提交以包含在作品中并由您定义的Apache-2.0许可证所涵盖的贡献,均应按照上述方式双授权,不附加任何额外条款或条件。

依赖关系

~1–7MB
~27K SLoC