Skip to content

Commit

Permalink
Make parsing %::z conform to documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker committed Jul 7, 2023
1 parent c57036d commit 420e068
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ pub enum Fixed {
TimezoneOffsetColon,
/// Offset from the local time to UTC with seconds (`+09:00:00` or `-04:00:00` or `+00:00:00`).
///
/// In the parser, the colon can be omitted and/or surrounded with any amount of whitespace.
/// The offset is limited from `-24:00:00` to `+24:00:00`,
/// which is the same as [`FixedOffset`](../offset/struct.FixedOffset.html)'s range.
TimezoneOffsetDoubleColon,
Expand Down
12 changes: 11 additions & 1 deletion src/format/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,6 @@ where
}

&TimezoneOffsetColon
| &TimezoneOffsetDoubleColon
| &TimezoneOffset
| &TimezoneOffsetColonZ
| &TimezoneOffsetZ => {
Expand All @@ -540,6 +539,17 @@ where
parsed.set_offset(i64::from(offset)).map_err(|e| (s, e))?;
}

&TimezoneOffsetDoubleColon => {
let offset_format = OffsetFormat {
precision: OffsetPrecision::Seconds,
colons: Colons::Colon,
allow_zulu: false,
padding: Pad::Zero,
};
let offset = try_consume!(scan::utc_offset(s.trim_start(), offset_format));
parsed.set_offset(i64::from(offset)).map_err(|e| (s, e))?;
}

&TimezoneOffsetTripleColon => {
let offset_format = OffsetFormat {
precision: OffsetPrecision::Hours,
Expand Down

0 comments on commit 420e068

Please sign in to comment.