Skip to content

Commit

Permalink
Add test for localized formatting of %X
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker committed Feb 10, 2024
1 parent 73388ca commit 5fb4fab
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/format/strftime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,22 @@ mod tests {
);
}

#[test]
#[cfg(all(feature = "unstable-locales", feature = "alloc"))]
fn test_strftime_localized_time() {
let dt1 = Utc.with_ymd_and_hms(2024, 2, 9, 6, 54, 32).unwrap();
let dt2 = Utc.with_ymd_and_hms(2024, 2, 9, 18, 54, 32).unwrap();
// Some of these locales gave issues before pure-rust-locales 0.8.0 with chrono 0.4.27+
assert_eq!(dt1.format_localized("%X", Locale::nl_NL).to_string(), "06:54:32");
assert_eq!(dt2.format_localized("%X", Locale::nl_NL).to_string(), "18:54:32");
assert_eq!(dt1.format_localized("%X", Locale::en_US).to_string(), "06:54:32 AM");
assert_eq!(dt2.format_localized("%X", Locale::en_US).to_string(), "06:54:32 PM");
assert_eq!(dt1.format_localized("%X", Locale::hy_AM).to_string(), "06:54:32");
assert_eq!(dt2.format_localized("%X", Locale::hy_AM).to_string(), "18:54:32");
assert_eq!(dt1.format_localized("%X", Locale::chr_US).to_string(), "06:54:32 ᏌᎾᎴ");
assert_eq!(dt2.format_localized("%X", Locale::chr_US).to_string(), "06:54:32 ᏒᎯᏱᎢᏗᏢ");
}

#[test]
#[cfg(all(feature = "unstable-locales", target_pointer_width = "64"))]
fn test_type_sizes() {
Expand Down

0 comments on commit 5fb4fab

Please sign in to comment.