From 260342a59228c0f2cbdb4eec5ebbb513d9516d50 Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Mon, 28 Mar 2016 09:43:52 -0700 Subject: [PATCH] Add regression test for RFC850 parsing Although not supported directly by chrono, users should be able to specify the RFC850 format and expect it to parse properly. RFC850 is important since HTTP/1.1 specifies HTTP-date = rfc1123-date | rfc850-date | asctime-date --- src/format/parse.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/format/parse.rs b/src/format/parse.rs index 6896d65..316cfac 100644 --- a/src/format/parse.rs +++ b/src/format/parse.rs @@ -635,6 +635,25 @@ fn test_rfc2822() { }; } + + +#[cfg(test)] +#[test] +fn parse_rfc850() { + use ::{UTC, TimeZone}; + + static RFC850_FMT: &'static str = "%A, %d-%b-%y %T GMT"; + + let dt_str = "Sunday, 06-Nov-94 08:49:37 GMT"; + let dt = UTC.ymd(1994, 11, 6).and_hms(8, 49, 37); + + // Check that the format is what we expect + assert_eq!(dt.format(RFC850_FMT).to_string(), dt_str); + + // Check that it parses correctly + assert_eq!(Ok(dt), UTC.datetime_from_str("Sunday, 06-Nov-94 08:49:37 GMT", RFC850_FMT)); +} + #[cfg(test)] #[test] fn test_rfc3339() {