Skip to content

Commit

Permalink
Test numeric time zone names
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker committed Sep 9, 2024
1 parent 2a675e2 commit 2e95510
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions chrono-tz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ pub use crate::IANA_TZDB_VERSION;

#[cfg(test)]
mod tests {
use super::Africa::Addis_Ababa;
use super::America::Danmarkshavn;
use super::America::Scoresbysund;
use super::Antarctica::Casey;
use super::Asia::Dhaka;
use super::Australia::Adelaide;
use super::Europe::Berlin;
Expand Down Expand Up @@ -496,4 +499,19 @@ mod tests {
assert_eq!(4, numbers.len());
assert!(IANA_TZDB_VERSION.ends_with(|c: char| c.is_ascii_lowercase()));
}

#[test]
fn test_numeric_names() {
let dt = Scoresbysund
.with_ymd_and_hms(2024, 05, 01, 0, 0, 0)
.unwrap();
assert_eq!(format!("{}", dt.offset()), "-01");
assert_eq!(format!("{:?}", dt.offset()), "-01");
let dt = Casey.with_ymd_and_hms(2022, 11, 01, 0, 0, 0).unwrap();
assert_eq!(format!("{}", dt.offset()), "+11");
assert_eq!(format!("{:?}", dt.offset()), "+11");
let dt = Addis_Ababa.with_ymd_and_hms(1937, 02, 01, 0, 0, 0).unwrap();
assert_eq!(format!("{}", dt.offset()), "+0245");
assert_eq!(format!("{:?}", dt.offset()), "+0245");
}
}

0 comments on commit 2e95510

Please sign in to comment.