[PATCH 2/5 v2] cmd: %time% should have 1/100s resolution and no leading zero.
Francois Gouget
fgouget at codeweavers.com
Fri Mar 25 10:15:27 CDT 2022
Stub out the subsecond decimals.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52719
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
v2:
- Move the tests to a separate patch
- Replace the leading zero by a space.
GetTimeFormatEx() does not support formatting fractions of a second. So
just stub out that until there is a need for it. At least now echo
%time% can be used to see where a batch file spends its time.
---
programs/cmd/tests/test_builtins.cmd.exp | 2 +-
programs/cmd/wcmdmain.c | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index 15fda131a5c..9075b4e3246 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -1223,7 +1223,7 @@ CD value @pwd@@or_broken at CD value at space@
@todo_wine at Match
@todo_wine at Has %errorlevel%
@todo_wine at Has %time%
- at todo_wine@%time% has seconds
+%time% has seconds
@todo_wine@%time% has 1/100s
End of %time%
@todo_wine at Match
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index af54b209d83..318e8e6e454 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -621,8 +621,12 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
NULL, thisVarContents, MAXSTRING);
len = lstrlenW(thisVarContents);
} else if (WCMD_is_magic_envvar(thisVar, L"TIME")) {
- GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL,
+ GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL,
NULL, thisVarContents, MAXSTRING);
+ /* FIXME This should have 1/100s precision and a localized decimal
+ * separator. */
+ if (*thisVarContents == '0') *thisVarContents = ' ';
+ lstrcatW(thisVarContents, L".00");
len = lstrlenW(thisVarContents);
} else if (WCMD_is_magic_envvar(thisVar, L"CD")) {
GetCurrentDirectoryW(MAXSTRING, thisVarContents);
--
2.30.2
More information about the wine-devel
mailing list