winnow_iso8601

Crates.iowinnow_iso8601
lib.rswinnow_iso8601
version0.6.0
created_at2024-11-15 14:43:36.162612+00
updated_at2025-05-30 22:24:31.964961+00
descriptionParsing ISO8601 dates using winnow
homepage
repositoryhttps://github.com/soulstompp/winnow-datetime
max_upload_size
id1449187
size178,553
Kenny Flegal (soulstompp)

documentation

https://docs.rs/winnow-iso8601/

README

winnow-iso8601, making parsing ISO8601 dates a breeze

crates.io docs.rs docs

About

This library contains parsers for parsing ISO8601 dates and their various components built off the winnow-datetime parsers

Parsing

Complete

If you have all the data you need, you can just pass along the input directly.

let datetime = opt(datetime)
    .parse_next(&mut "2015-06-26T16:43:23+0200"));

// the above will give you:
Some(DateTime {
    date: Date::YMD {
        year: 2015,
        month: 6,
        day: 26,
    },
    time: Time {
        hour: 16,
        minute: 43,
        second: 23,
        tz_offset_hours: 2,
        tz_offset_minutes: 0,
    },
});

Partial

For partial data the only difference is wrapping input in Partial and handling incomplete errors correctly, which is documented in winnow partial docs.

pub type Stream<'i> = Partial<&'i [u8]>;

let datetime = opt(datetime)
    .parse_next(&mut Stream::new("2015-06-26T16:43:23+0200").as_bytes()));

// the above will give you:
Some(DateTime {
    date: Date::YMD {
        year: 2015,
        month: 6,
        day: 26,
    },
    time: Time {
        hour: 16,
        minute: 43,
        second: 23,
        tz_offset_hours: 2,
        tz_offset_minutes: 0,
    },
});

Contributors

winnow-iso8601 is the fruit of the work of many contributors over the years, many thanks for your help! In particular, thanks to badboy and hoodie for the original iso8601 crate and actually reading the standard.

Documentation

Documentation is online.

License

MIT Licensed. See LICENSE

Commit count: 258

cargo fmt