1 unstable release

0.1.0 Nov 26, 2023

#1401 in Web programming

Download history 10/week @ 2023-12-18 49/week @ 2023-12-25 93/week @ 2024-01-01 3/week @ 2024-01-15 41/week @ 2024-01-22 49/week @ 2024-01-29 11/week @ 2024-02-12 25/week @ 2024-02-19 43/week @ 2024-02-26 4/week @ 2024-03-04 10/week @ 2024-03-11 4/week @ 2024-03-18 71/week @ 2024-04-01

86 downloads per month
Used in 2 crates

GPL-3.0-or-later

15KB
100 lines

mwtimestamp

crates.io docs.rs

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


lib.rs:

mwtimestamp

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!

Dependencies

~1.5–8MB
~48K SLoC