From 9abaf30ecfed4d0c65b9a8682ba5f676b14ae61d Mon Sep 17 00:00:00 2001 From: Jacob Pratt Date: Sat, 23 Sep 2023 20:45:40 -0400 Subject: [PATCH] Revert default for `OffsetHour` modifier The values was mistakenly changed and was originally `false`. This change brings behavior in line with parsing the component. --- time/src/format_description/modifier.rs | 6 +++--- time/src/serde/mod.rs | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/time/src/format_description/modifier.rs b/time/src/format_description/modifier.rs index b145e60cc..3a57bb6f6 100644 --- a/time/src/format_description/modifier.rs +++ b/time/src/format_description/modifier.rs @@ -392,10 +392,10 @@ impl_const_default! { /// Creates a modifier that indicates the stringified value contains [one or more /// digits](SubsecondDigits::OneOrMore). @pub Subsecond => Self { digits: SubsecondDigits::OneOrMore }; - /// Creates a modifier that indicates the value uses the `+` sign for all positive values - /// and is [padded with zeroes](Padding::Zero). + /// Creates a modifier that indicates the value only uses a sign for negative values and is + /// [padded with zeroes](Padding::Zero). @pub OffsetHour => Self { - sign_is_mandatory: true, + sign_is_mandatory: false, padding: Padding::Zero, }; /// Creates a modifier that indicates the value is [padded with zeroes](Padding::Zero). diff --git a/time/src/serde/mod.rs b/time/src/serde/mod.rs index 7e3403fb3..f94cf0445 100644 --- a/time/src/serde/mod.rs +++ b/time/src/serde/mod.rs @@ -403,7 +403,11 @@ impl<'a> Deserialize<'a> for Time { /// The format used when serializing and deserializing a human-readable `UtcOffset`. #[cfg(feature = "parsing")] const UTC_OFFSET_FORMAT: &[FormatItem<'_>] = &[ - FormatItem::Component(Component::OffsetHour(modifier::OffsetHour::default())), + FormatItem::Component(Component::OffsetHour({ + let mut m = modifier::OffsetHour::default(); + m.sign_is_mandatory = true; + m + })), FormatItem::Optional(&FormatItem::Compound(&[ FormatItem::Literal(b":"), FormatItem::Component(Component::OffsetMinute(modifier::OffsetMinute::default())),