Commit Graph
125 Commits
Author SHA1 Message Date
Devel08GitHubpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
5fa0aba94d date: don't ignore width prefix in %N format specifier (#12010)
* do not ignore %N if specified width is smaller than default width

* add test for issue #12001

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* cargo clippy

* truncate instead of popping in a loop

* Update format_modifiers.rs

* skip truncation if width is 0

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-04-27 14:59:09 +02:00
oech3andDaniel Hofstetter 9978ac67f2 date: use cfg unix 2026-04-23 09:02:29 +02:00
Sylvestre LedruandDaniel Hofstetter c4093734e2 ci: install hu_HU.UTF-8 (and peers) for l10n cargo test job 2026-04-06 15:10:31 +02:00
MegaBrutalandDaniel Hofstetter 0a5c60f5cf Tests for Hungarian locale 2026-04-06 15:10:31 +02:00
vishakha1411andDaniel Hofstetter 51094702d2 date: honor narrow width on wide default strftime fields 2026-04-06 10:16:00 +02:00
vishakha1411andDaniel Hofstetter b41d591cde date: fix %#P case-swap on lowercase am/pm 2026-04-06 09:48:18 +02:00
Sylvestre Ledru 88fb82a4a7 date: add ignored tests for GNU compatibility gaps found by fuzz_date 2026-04-05 23:49:37 +02:00
Sylvestre Ledru 9ebeacb84d Modify spell-checker ignore comments
Updated spell-checker ignore list in test_date.rs
2026-04-05 10:13:31 +02:00
Sylvestre Ledru dbdd2ddfda date: extract try_alloc_padded helper and add large-width test
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2026-04-05 10:13:31 +02:00
mattsuandSylvestre Ledru c81e9d00b9 fix: improve error handling for format modifier width parsing
- Changed FormatError::FieldWidthTooLarge to store width as String instead of usize
- Updated error message generation to use FluentArgs for proper localization
- Fixed width parsing to return FormatError instead of panicking on parse failure
- Updated error message formatting to use get_message_with_args for consistency
- Fixed test assertions to compare width as String instead of usize
2026-04-05 10:13:31 +02:00
mattsuandSylvestre Ledru 12b30cbca1 fix(date): add error handling for format modifier width overflow
Added proper error handling for format modifier width calculations that could overflow or fail allocation. The change replaces generic error messages with a specific error type `FieldWidthTooLarge` that includes the problematic width and specifier values, improving error reporting for date format operations.
2026-04-05 10:13:31 +02:00
mattsuandSylvestre Ledru 136b1841b3 fix(date): handle width overflow in format modifiers
Update `apply_modifiers` to return `Result<String, FormatError>` and check for integer overflow when calculating padding length. This prevents potential panics or incorrect formatting when very large width values are specified. The change adds proper error handling for the "field width too large" case and propagates errors through the formatting pipeline.
2026-04-05 10:13:31 +02:00
Sylvestre LedruandDaniel Hofstetter ffa088d467 tests: deduplicate locale availability checks into shared is_locale_available() 2026-04-01 14:36:58 +02:00
xtqqczzeandGitHub f00a050106 clippy: fix nightly lints (#11232) 2026-03-08 09:13:23 +01:00
cerdelenandDaniel Hofstetter a6b0276966 date: extend tz abbreviation lookup 2026-03-07 16:46:48 +01:00
Cả thế giới là RustandGitHub 2c3eab9440 date: fix %+ and %_ modifier edge cases (#10999)
* date: fix %+ and %_ modifier edge cases

Fixes #10957:

1. %+ without explicit width now correctly omits sign for years
   with <= 4 digits. Sign is only added when explicit width is
   provided or year exceeds default width.

2. %_ without explicit width now correctly pads to the specifier's
   default width (e.g., %_m produces " 6" instead of "6").

Changes:
- Add get_default_width() function mapping specifiers to POSIX
  default widths
- Modify apply_modifiers() to accept explicit_width parameter
- Update tests for new behavior

Test results:
- date -d '1999-06-01' '+%+Y' -> "1999" (was "+1999")
- date -d '1999-06-01' '+%_m' -> " 6" (was "6")
2026-02-27 09:13:59 +01:00
Alvaro GuimaraesandDaniel Hofstetter e4cc92ba46 date: fix timezone abbreviations using wrong offset outside their DST season 2026-02-21 16:28:56 +01:00
yachiandDaniel Hofstetter 8c98b152c6 date: fix -d with relative dates and timezone abbreviations
`try_parse_with_abbreviation` resolved relative dates like "yesterday"
against the system clock instead of the caller-provided reference time.
Pass `now` through so both code paths use the same reference.

Fixes #10788
2026-02-19 11:00:55 +01:00
b4395348c8 date: Fix Error message missing '+' for format string after valid d flag (#10982)
* date: Fix Errors message missing '+' for format string after valid d flag

* Update src/uu/date/locales/fr-FR.ftl

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>

---------

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2026-02-17 09:28:58 +01:00
Sylvestre LedruandGitHub a7f55cbedc date: fix subfmt-up1, fill-1, pct-pct, and invalid-high-bit-set tests (#10940) 2026-02-15 09:14:29 -08:00
72c782fbfd date: fix double periods in Hungarian month abbreviations (#10945)
ICU's DateTimeFormatter with fieldsets::M::medium() returns month
abbreviations with trailing periods (e.g., "febr." for Hungarian).
When the Hungarian locale format string contains "%Y. %b. %d"
(with periods after year and month), the ICU output resulted in
double periods: "febr.."

This fix strips trailing periods from ICU month abbreviations to
match the standard C/POSIX locale behavior.

Also adds a new test case for abbreviated month names across
multiple locales to prevent regression.

Fixes #10921

Co-authored-by: naoNao89 <naoNao89@users.noreply.github.com>
2026-02-15 13:15:29 +01:00
Sylvestre LedruandGitHub 6d9af5ae77 date: add tests to match GNU's (#10939)
* date: add test for rel-2b GNU test

Test correct month arithmetic maintaining same day of month, and
month overflow when day doesn't exist in target month.

* date: add test for cross-TZ-mishandled GNU test

Test parsing dates with embedded timezone specifications.
2026-02-14 13:55:16 -08:00
Sylvestre LedruandGitHub c4e3ca658a date: bump parse_datetime & add test for leap-1 GNU test (#10933)
Rely on parse_datetime update

Test that adding years to Feb 29 overflows to March 1 when target
year is not a leap year (matching GNU behavior).
2026-02-14 21:53:17 +01:00
Sylvestre LedruandGitHub 5dcdba102e date: fix RFC-822 format to always use English names (#10932)
fixed gnu rfc822-1

RFC-822/RFC-2822/RFC-5322 formats must use English day and month names
regardless of locale per RFC specification. Previously, these formats
were being localized (e.g., "So" instead of "Sun" with de_DE locale).
2026-02-14 11:39:45 -08:00
cerdelenandGitHub e4b3b5ca72 date: Fix format optional argument to capture all following parameters (#10914) 2026-02-13 16:13:01 -05:00