Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions src/uu/date/src/locale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@
macro_rules! cfg_langinfo {
($($item:item)*) => {
$(
#[cfg(any(
target_os = "linux",
target_vendor = "apple",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "dragonfly"
))]
#[cfg(all(unix, not(target_os = "android"), not(target_os = "redox")))]
$item
)*
}
Expand Down Expand Up @@ -117,14 +110,7 @@ cfg_langinfo! {
}

/// On platforms without nl_langinfo support, use 24-hour format by default
#[cfg(not(any(
target_os = "linux",
target_vendor = "apple",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "dragonfly"
)))]
#[cfg(any(not(unix), target_os = "android", target_os = "redox"))]
pub fn get_locale_default_format() -> &'static str {
"%a %b %e %X %Z %Y"
}
Expand Down
18 changes: 2 additions & 16 deletions src/uucore/src/lib/features/i18n/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,7 @@ pub fn get_locale_months() -> Option<&'static [Vec<u8>; 12]> {
}

/// Unix implementation using nl_langinfo for exact match with `locale abmon` output.
#[cfg(any(
target_os = "linux",
target_vendor = "apple",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "dragonfly"
))]
#[cfg(all(unix, not(target_os = "android"), not(target_os = "redox")))]
fn get_locale_months_inner() -> Option<[Vec<u8>; 12]> {
use nix::libc;
use std::ffi::CStr;
Expand Down Expand Up @@ -228,14 +221,7 @@ fn get_locale_months_inner() -> Option<[Vec<u8>; 12]> {
}

/// Non-Unix fallback using ICU DateTimeFormatter.
#[cfg(not(any(
target_os = "linux",
target_vendor = "apple",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "dragonfly"
)))]
#[cfg(any(not(unix), target_os = "android", target_os = "redox"))]
fn get_locale_months_inner() -> Option<[Vec<u8>; 12]> {
let (locale, _) = get_time_locale();
let locale_prefs = locale.clone().into();
Expand Down
27 changes: 3 additions & 24 deletions tests/by-util/test_date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1398,14 +1398,7 @@ fn test_date_locale_hour_c_locale() {
}

#[test]
#[cfg(any(
target_os = "linux",
target_vendor = "apple",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "dragonfly"
))]
#[cfg(unix)]
fn test_date_locale_hour_en_us() {
// en_US locale typically uses 12-hour format when available
// Note: If locale is not installed on system, falls back to C locale (24-hour)
Expand Down Expand Up @@ -1440,14 +1433,7 @@ fn test_date_explicit_format_overrides_locale() {

// Comprehensive locale formatting tests to verify actual locale format strings are used
#[test]
#[cfg(any(
target_os = "linux",
target_vendor = "apple",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "dragonfly"
))]
#[cfg(unix)]
fn test_date_locale_leading_zeros_en_us() {
// Test for leading zeros in en_US locale
// en_US uses %I (01-12) with leading zeros, not %l (1-12) without
Expand Down Expand Up @@ -1576,14 +1562,7 @@ fn test_date_locale_format_not_hardcoded() {
}

#[test]
#[cfg(any(
target_os = "linux",
target_vendor = "apple",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "dragonfly"
))]
#[cfg(unix)]
fn test_date_locale_en_us_vs_c_difference() {
// Verify that en_US and C locales produce different outputs
// (if en_US locale is available on the system)
Expand Down
Loading