winnow_rfc9557

Crates.iowinnow_rfc9557
lib.rswinnow_rfc9557
version0.1.0
created_at2025-05-30 22:25:04.633145+00
updated_at2025-05-30 22:25:04.633145+00
descriptionParsing RFC 9557 dates using winnow
homepage
repositoryhttps://github.com/soulstompp/winnow-datetime
max_upload_size
id1695727
size59,885
Kenny Flegal (soulstompp)

documentation

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

README

winnow-rfc9557, making parsing RFC9557 dates a breeze

crates.io docs.rs docs

About

This library contains parsers for parsing RFC9557 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-26 16: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-26 16: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,
    },
});

Caveats

Timezone Suffixes

The critical flag for suffixes are parsed according to the spec and saved in the AST but don't have an effect on exports to jiff (the only crate that currently handles timezones correctly). At the moment, if the offset or timezone was set in the suffix it simply takes precedence.

Calendar Suffixes

Per the spec, multiple calendar suffixes are allowed, but only the first one is parsed and used. The rest are ignored even if the critical flag is set.

Contributors

winnow-rfc9557 is the fruit of the work of many contributors over the years, many thanks for your help!

Documentation

Documentation is online.

License

MIT Licensed. See LICENSE

Commit count: 258

cargo fmt