[PATCH 4/5 v2] cmd: Fix the output of date /t and time /t.
Francois Gouget
fgouget at codeweavers.com
Fri Mar 25 10:15:35 CDT 2022
They just output the date / time, without any explanatory text.
Furthermore time /t only returns the time down to the minute.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52719
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
v2:
- Add a trailing space to date /t.
---
programs/cmd/builtins.c | 22 +++++++++++++++++-----
programs/cmd/tests/test_builtins.cmd.exp | 4 ++--
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 963a9eaf361..d3d62d7dc56 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -3503,14 +3503,20 @@ void WCMD_setshow_date (void) {
if (!*param1) {
if (GetDateFormatW(LOCALE_USER_DEFAULT, 0, NULL, NULL, curdate, ARRAY_SIZE(curdate))) {
- WCMD_output (WCMD_LoadMessage(WCMD_CURRENTDATE), curdate);
if (wcsstr(quals, L"/T") == NULL) {
+ WCMD_output (WCMD_LoadMessage(WCMD_CURRENTDATE), curdate);
WCMD_output (WCMD_LoadMessage(WCMD_NEWDATE));
WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), buffer, ARRAY_SIZE(buffer), &count);
if (count > 2) {
WCMD_output_stderr (WCMD_LoadMessage(WCMD_NYI));
}
}
+ else {
+ WCMD_output (curdate);
+ /* The tests show there is a trailing space, maybe to make it easier
+ * to append the time. */
+ WCMD_output (L" ");
+ }
}
else WCMD_print_error ();
}
@@ -4291,17 +4297,23 @@ void WCMD_setshow_time (void) {
if (!*param1) {
GetLocalTime(&st);
- if (GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, curtime, ARRAY_SIZE(curtime))) {
- WCMD_output (WCMD_LoadMessage(WCMD_CURRENTTIME), curtime);
- if (wcsstr(quals, L"/T") == NULL) {
+ if (wcsstr(quals, L"/T") == NULL) {
+ if (GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, curtime, ARRAY_SIZE(curtime))) {
+ WCMD_output (WCMD_LoadMessage(WCMD_CURRENTTIME), curtime);
WCMD_output (WCMD_LoadMessage(WCMD_NEWTIME));
WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), buffer, ARRAY_SIZE(buffer), &count);
if (count > 2) {
WCMD_output_stderr (WCMD_LoadMessage(WCMD_NYI));
}
}
+ else WCMD_print_error ();
+ }
+ else {
+ if (GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, curtime, ARRAY_SIZE(curtime))) {
+ WCMD_output (curtime);
+ }
+ else WCMD_print_error ();
}
- else WCMD_print_error ();
}
else {
WCMD_output_stderr (WCMD_LoadMessage(WCMD_NYI));
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index 00224d033c6..0d55d6b8630 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -1220,13 +1220,13 @@ WINE_bar correctly 6 at or_broken@ERROR: WINE_bar incorrectly 5 [6]
CD value @pwd@@or_broken at CD value at space@
@todo_wine at Has %date%
Good %date%
- at todo_wine@Match
+Match
@todo_wine at Has %errorlevel%
@todo_wine at Has %time%
%time% has seconds
%time% has 1/100s
End of %time%
- at todo_wine@Match
+Match
@todo_wine at Has %random%
%random% looks random
--- for /F
--
2.30.2
More information about the wine-devel
mailing list