Why doesn't BIFF_LOCALE=en-NZ-u-hc-h24 for TZ=Pacific/Auckland use a 24 hour clock?
#5
-
|
Following from the Guide... let's say I'm in New Zealand: but I don't like the 12-hour clock: uhhhh, what? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 13 replies
-
|
TL;DR - Use I actually wasn't sure which time zone identifier you were using, because that can impact localization. So I did: I'm guessing you're in I'm not a locale expert, so I don't know if this is a bug in ICU4X or if this is a problem in how I'm using ICU4X. cc @sffc For ICU4X, we'll need a Rust program using their library directly for this to be actionable for them I think. So I'll take my example from [package]
publish = false
name = "jiff-icu-new-zealand-24hr"
version = "0.1.0"
edition = "2024"
[dependencies]
anyhow = "1.0.98"
icu = "2.0.0"
jiff = "0.2.13"
jiff-icu = "0.2.0"
[[bin]]
name = "jiff-icu-new-zealand-24hr"
path = "main.rs"
[profile.release]
debug = trueAnd use icu::{
calendar::Iso,
datetime::{fieldsets, DateTimeFormatter},
locale::locale,
time::ZonedDateTime,
};
use jiff::Zoned;
use jiff_icu::ConvertFrom as _;
fn main() -> anyhow::Result<()> {
let zdt: Zoned = "2025-05-10T17:30[Pacific/Auckland]".parse()?;
let icu_zdt = ZonedDateTime::<Iso, _>::convert_from(&zdt);
// Format for the en-GB locale:
let formatter = DateTimeFormatter::try_new(
locale!("en-NZ-u-hc-h24").into(),
fieldsets::YMDET::medium().with_zone(fieldsets::zone::SpecificLong),
)?;
assert_eq!(
formatter.format(&icu_zdt).to_string(),
"Sat, 10/05/2025, 5:30:00\u{202f}pm New Zealand Standard Time",
);
Ok(())
}Running this, the assertion above passes. Which means it isn't using a 24 hour clock rendering. My recollection is that ICU4X has an API for providing preferences for datetime formatting explicitly, instead of relying on a locale identifier. So when I went looking for that, I found Apparently. You need to use I struggled to find a "locale identifiers for humans" text when I was writing Biff's docs. It's extremely opaque to me what the domain of values are and what I'm actually able to express. |
Beta Was this translation helpful? Give feedback.
-
Yes, you need to use |
Beta Was this translation helpful? Give feedback.
TL;DR - Use
BIFF_LOCALE=en-NZ-u-hc-h23instead.I actually wasn't sure which time zone identifier you were using, because that can impact localization. So I did:
I'm guessing you're in
Pacific/Auckland? Here's a more reliable way to reproduce: