diff --git a/src/format/mod.rs b/src/format/mod.rs index 2071de6387..12f316a3e4 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -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, diff --git a/src/format/parse.rs b/src/format/parse.rs index 9cbcca78c3..69cb9a27df 100644 --- a/src/format/parse.rs +++ b/src/format/parse.rs @@ -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));