From cd47b5dd140d3eebd74f38114a37b07e39482c52 Mon Sep 17 00:00:00 2001 From: Mike Cronce Date: Wed, 28 Jun 2023 11:35:54 -0400 Subject: [PATCH] src/offset/fixed.rs: Add tests for FixedOffset::from_str() --- src/offset/fixed.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/offset/fixed.rs b/src/offset/fixed.rs index a6bc8d15fe..fcf445fd97 100644 --- a/src/offset/fixed.rs +++ b/src/offset/fixed.rs @@ -259,6 +259,7 @@ impl Sub for DateTime { mod tests { use super::FixedOffset; use crate::offset::TimeZone; + use std::str::FromStr; #[test] fn test_date_extreme_offset() { @@ -305,4 +306,14 @@ mod tests { "2012-03-04T05:06:07-23:59:59".to_string() ); } + + #[test] + fn test_parse_offset() { + let offset = FixedOffset::from_str("-0500").unwrap(); + assert_eq!(offset.local_minus_utc, -5 * 3600); + let offset = FixedOffset::from_str("-08:00").unwrap(); + assert_eq!(offset.local_minus_utc, -8 * 3600); + let offset = FixedOffset::from_str("+06:30").unwrap(); + assert_eq!(offset.local_minus_utc, (6 * 3600) + 1800); + } }