Skip to content

Commit

Permalink
src/offset/fixed.rs: Add tests for FixedOffset::from_str()
Browse files Browse the repository at this point in the history
  • Loading branch information
mcronce committed Jun 28, 2023
1 parent 5ad4be8 commit 58efae4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/offset/fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ impl<Tz: TimeZone> Sub<FixedOffset> for DateTime<Tz> {
mod tests {
use super::FixedOffset;
use crate::offset::TimeZone;
use std::str::FromStr;

#[test]
fn test_date_extreme_offset() {
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 58efae4

Please sign in to comment.