Skip to content

Commit

Permalink
Fold permissive parsing into timezone_offset()
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Jun 29, 2023
1 parent 5293ed7 commit 69456af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
7 changes: 5 additions & 2 deletions src/format/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,12 @@ where
&Internal(InternalFixed {
val: InternalInternal::TimezoneOffsetPermissive,
}) => {
let offset = try_consume!(scan::timezone_offset_permissive(
let offset = try_consume!(scan::timezone_offset(
s.trim_start(),
scan::colon_or_space
scan::colon_or_space,
true,
true,
true,
));
parsed.set_offset(i64::from(offset)).map_err(|e| (s, e))?;
}
Expand Down
9 changes: 0 additions & 9 deletions src/format/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,6 @@ where
Ok((s, if negative { -seconds } else { seconds }))
}

/// Same as `timezone_offset` but also allows for `z`/`Z` which is the same as
/// `+00:00`, and allows missing minutes entirely.
pub(super) fn timezone_offset_permissive<F>(s: &str, colon: F) -> ParseResult<(&str, i32)>
where
F: FnMut(&str) -> ParseResult<&str>,
{
timezone_offset(s, colon, true, true, true)
}

/// Same as `timezone_offset` but also allows for RFC 2822 legacy timezones.
/// May return `None` which indicates an insufficient offset data (i.e. `-0000`).
/// See [RFC 2822 Section 4.3].
Expand Down

0 comments on commit 69456af

Please sign in to comment.