Skip to content

fix(date): keep POSIX '.' in custom --date fractional seconds - #1227

Open
pnavais wants to merge 1 commit into
lsd-rs:mainfrom
pnavais:fix/custom-date-format-posix-fractional
Open

fix(date): keep POSIX '.' in custom --date fractional seconds#1227
pnavais wants to merge 1 commit into
lsd-rs:mainfrom
pnavais:fix/custom-date-format-posix-fractional

Conversation

@pnavais

@pnavais pnavais commented Aug 6, 2026

Copy link
Copy Markdown

Summary

After #820, custom --date / TIME_STYLE=+… formats went through format_localized(). Chrono then uses the locale decimal separator for %.Nf, so locales like es_ES, de_DE, and fr_FR emit , instead of ..

That breaks:

  • User-facing custom formats that expect POSIX strftime punctuation (e.g. +%Y-%m-%d %H:%M:%.3f)
  • tests/integration.rs::test_date_custom_format_supports_nanos_with_length, which matches testDateFormat\.[0-9]{3}

DateFlag::Locale still uses format_localized() for intentional localization. Custom formats use non-localized format() again.

This may also explain failures reported in #1223 on macOS when the system locale is non-English (via sys-locale), independent of APFS timestamp precision — that test only asserts the %.3f pattern appears twice; it does not require distinct nanosecond values.

Verification

en_US: format_localized("%.3f") => .NNN
es_ES: format_localized("%.3f") => ,NNN
plain format("%.3f")            => .NNN  (all locales)
  • cargo test custom_format — unit + integration tests pass
  • cargo fmt

TODO

  • Use cargo fmt
  • Add necessary tests
  • Update README (if applicable)
  • Update config sample file in doc/samples (if applicable)
  • Update icon sample file in doc/samples (if applicable)
  • Update color sample file in doc/samples (if applicable)
  • Update man page at lsd/doc/lsd.md (if applicable)

PR lsd-rs#820 applied format_localized() to DateFlag::Formatted, which uses a
locale decimal separator (',' in es_ES/de_DE/fr_FR). Custom strftime
formats and the nanos integration test expect a POSIX '.'.

Use non-localized format() for custom formats; DateFlag::Locale still
uses format_localized().

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant