Struct email::rfc822::Rfc822DateParser [] [src]

pub struct Rfc822DateParser<'s> {
    // some fields omitted
}

Parser for RFC822 style dates, as defined by Section 5.

Note that this also supports the additions as specified in RFC5322 Section 3.3 while still being backward compatible. [unstable]

Methods

impl<'s> Rfc822DateParser<'s>

fn new(s: &'s str) -> Rfc822DateParser<'s>

[unstable]

fn consume_datetime(&mut self) -> ParsingResult<DateTime<FixedOffset>>

Consume a DateTime from the input.

If successful, returns a DateTime with a fixed offset based on the timezone parsed. You may wish to deal with this in UTC, in which case you may want something like

extern crate chrono;
extern crate email;

use email::rfc822::Rfc822DateParser;
use chrono::UTC;

fn main() {
    let mut p = Rfc822DateParser::new("Thu, 18 Dec 2014 21:07:22 +0100");
    let d = p.consume_datetime().unwrap();
    let as_utc = d.with_timezone(&UTC);

    assert_eq!(d, as_utc);
}

[unstable]