Skip to content

date - %x format specifier ignores locale settings #10284

@sylvestre

Description

@sylvestre

Rust (incorrect - uses US format regardless of locale)

  $ LC_ALL=fr_FR.UTF-8 cargo run -q --features unix -- date -d '1997-01-19 08:17:48' +%x
  01/19/97
  # Uses US format MM/DD/YY instead of locale-specific format

GNU (correct - respects locale)

  $ LC_ALL=fr_FR.UTF-8 /usr/bin/date -d '1997-01-19 08:17:48' +%x
  19/01/1997
  # Uses French format DD/MM/YYYY as expected

The %x format specifier should output the locale's date representation (obtained from
nl_langinfo(D_FMT)), but uutils uses a hardcoded US format.

This also affects %X (locale time format) and %r (locale 12-hour time format) which should use
nl_langinfo(T_FMT) and nl_langinfo(T_FMT_AMPM) respectively.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions