coreutils
coreutils copied to clipboard
fix #3756 on linux and make output closer to gnu date on other oses
makes date
output identical to date
from the gnu core utils on Linux (as far as I tested).
output on windows and mac is still not identical redox not tested
additional crates : https://crates.io/crates/libc-strftime (MIT license)
tested on Linux, Mac os and Windows
ps : I accidentally pulled a commit form the main branch, but I didn't modify anything about ls
Please a test for your change :) See https://github.com/uutils/coreutils/blob/main/tests/by-util/test_date.rs for other examples
This feels like a temporary (but good!) solution. What would need to happen to solve this permanently? Are there issues we can reference in the code so we can keep track of the progress of fixing this in chrono for example?
i agree this is definitely not an ideal solution, but at least it works for now. here's a list (from memory, so probably non exhaustive) of things that would need to be fixed in chrono in order to have a more elegant solution :
-
fixing locale-dependent formatting specifiers like "%c" and "%X" in
chrono::format()
(see https://docs.rs/chrono/0.4.19/chrono/format/strftime/index.html). issue : https://github.com/chronotope/chrono/issues/708 -
fix the "%Z" specifier (timezone) doesn't behave like expected in
chrono::format()
: prints offset from the local timezone and UTC instead of the name of the timezone. issue : https://github.com/chronotope/chrono/issues/749 -
chrono::format_localized()
(enabled with chrono'sunstable-locales
feature) doesn't auto detect locale, and doesn't allow specifying a locale as a String, only achrono::Locale
and i couldn't find any way to get achrono::Locale
from a String (there's no issue as it's intended, although limiting behavior)
I'll reference both issues in the code
Thanks!
I guess you saw:
---- test_date::test_date_format_day stdout ----
current_directory_resolved:
run: D:\a\coreutils\coreutils\target\debug\coreutils.exe date +%a
run: D:\a\coreutils\coreutils\target\debug\coreutils.exe date +%A
run: D:\a\coreutils\coreutils\target\debug\coreutils.exe date +%u
---- test_date::test_date_format_day stderr ----
thread 'main' panicked at 'Stdout does not match regex:
', tests\common\util.rs:446:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---- test_date::test_date_nano_seconds stdout ----
current_directory_resolved:
run: D:\a\coreutils\coreutils\target\debug\coreutils.exe date +%N
---- test_date::test_date_nano_seconds stderr ----
thread 'main' panicked at 'Stdout does not match regex:
', tests\common\util.rs:446:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---- test_date::test_date_rfc_3339 stdout ----
current_directory_resolved:
run: D:\a\coreutils\coreutils\target\debug\coreutils.exe date --rfc-3339=ns
---- test_date::test_date_rfc_3339 stderr ----
thread 'main' panicked at 'Stdout does not match regex:
', tests\common\util.rs:446:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failures:
test_date::test_date_format_day
test_date::test_date_nano_seconds
test_date::test_date_rfc_3339
closing as I don't have time to work on it