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 Jun 12, 2023
1 parent bca6764 commit 257fa20
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ pub enum Fixed {
TimezoneName,
/// Offset from the local time to UTC (`+09:00` or `-04:00` or `+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` to `+24:00`,
/// which is the same as [`FixedOffset`](../offset/struct.FixedOffset.html)'s range.
TimezoneOffsetColon,
Expand Down
18 changes: 13 additions & 5 deletions src/format/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,14 +460,22 @@ where
try_consume!(scan::timezone_name_skip(s));
}

&TimezoneOffsetColon
| &TimezoneOffset
| &TimezoneOffsetColonZ
| &TimezoneOffsetZ => {
&TimezoneOffset | &TimezoneOffsetZ => {
let offset_format = UtcOffsetFormat {
precision: OffsetPrecision::Minutes,
colons: Colon::Maybe,
allow_zulu: spec == &TimezoneOffsetColonZ || spec == &TimezoneOffsetZ,
allow_zulu: spec == &TimezoneOffsetZ,
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))?;
}

&TimezoneOffsetColon | &TimezoneOffsetColonZ => {
let offset_format = UtcOffsetFormat {
precision: OffsetPrecision::Minutes,
colons: Colon::Colon,
allow_zulu: spec == &TimezoneOffsetColonZ,
padding: Pad::Zero,
};
let offset = try_consume!(scan::utc_offset(s.trim_start(), offset_format));
Expand Down

0 comments on commit 257fa20

Please sign in to comment.