2 releases

0.1.1 Jun 2, 2024
0.1.0 Nov 26, 2023

#1445 in Web programming

Download history 169/week @ 2024-07-01 101/week @ 2024-07-08 96/week @ 2024-07-15 109/week @ 2024-07-22 131/week @ 2024-07-29 103/week @ 2024-08-05 106/week @ 2024-08-12 121/week @ 2024-08-19 186/week @ 2024-08-26 58/week @ 2024-09-02 56/week @ 2024-09-09 53/week @ 2024-09-16 81/week @ 2024-09-23 96/week @ 2024-09-30 129/week @ 2024-10-07 89/week @ 2024-10-14

403 downloads per month
Used in 2 crates

GPL-3.0-or-later

16KB
140 lines

mwtimestamp

crates.io docs.rs docs (main) pipeline status coverage report

mwtimestamp is a library for parsing and formatting MediaWiki timestamps, powered by chrono.

The MediaWiki API typically produces ISO 8601 timestamps. In some cases, like protection or block expiry, it may alternatively return the string "infinity" to represent that there is no end period.

use mwtimestamp::{Expiry, Timestamp};
// Deserializing a fixed timestamp
let finite: Timestamp = serde_json::from_str("\"2001-01-15T14:56:00Z\"").unwrap();
assert_eq!(
    finite.date_naive(),
    chrono::NaiveDate::from_ymd_opt(2001, 1, 15).unwrap(),
);
// Deserializing an infinite timestamp
let infinity: Expiry = serde_json::from_str("\"infinity\"").unwrap();
assert!(infinity.is_infinity());

Contributing

mwtimestamp is a part of the mwbot-rs project. We're always looking for new contributors, please reach out if you're interested!

License

This crate is released under GPL-3.0-or-later. See COPYING for details.

Dependencies

~1.4–6.5MB
~46K SLoC