Skip to content

Commit

Permalink
Add various tests for current parsing
Browse files Browse the repository at this point in the history
Add more varying testing for most parsing functions.
Tests emphasize whitespace, literals, timezones, and timezone
delimiters (colons and whitespace).

Add tests for multiple-byte characters and combining characters
in and around data and parsing formats.

These tests are added to aid humans verifying the next commit that
changes parsing behavior.

Issue #660
  • Loading branch information
jtmoon79 authored and djc committed Mar 18, 2023
1 parent 1a0d47a commit eba2f26
Show file tree
Hide file tree
Showing 7 changed files with 1,652 additions and 81 deletions.
5 changes: 5 additions & 0 deletions src/datetime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,13 +523,18 @@ impl DateTime<FixedOffset> {
/// RFC 2822 is the internet message standard that specifies the representation of times in HTTP
/// and email headers.
///
/// The RFC 2822 standard allows arbitrary intermixed whitespace.
/// See [RFC 2822 Appendix A.5]
///
/// ```
/// # use chrono::{DateTime, FixedOffset, TimeZone, NaiveDate};
/// assert_eq!(
/// DateTime::<FixedOffset>::parse_from_rfc2822("Wed, 18 Feb 2015 23:16:09 GMT").unwrap(),
/// FixedOffset::east_opt(0).unwrap().with_ymd_and_hms(2015, 2, 18, 23, 16, 9).unwrap()
/// );
/// ```
///
/// [RFC 2822 Appendix A.5]: https://www.rfc-editor.org/rfc/rfc2822#appendix-A.5
pub fn parse_from_rfc2822(s: &str) -> ParseResult<DateTime<FixedOffset>> {
const ITEMS: &[Item<'static>] = &[Item::Fixed(Fixed::RFC2822)];
let mut parsed = Parsed::new();
Expand Down
Loading

0 comments on commit eba2f26

Please sign in to comment.