[PATCH 1/3] programs/cmd: %time% should have 1/100s resolution.
Francois Gouget
fgouget at codeweavers.com
Wed Mar 23 21:59:32 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>
---
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 | 9 +++++++++
programs/cmd/tests/test_builtins.cmd.exp | 2 ++
programs/cmd/wcmdmain.c | 5 ++++-
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd
index 3f410e55166..8133268d2dd 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -1789,6 +1789,15 @@ set /a WINE_foo=5
set /a WINE_bar=WINE_foo=6
call :checkenvvars WINE_foo 6 WINE_bar 6
+echo --- Magic environment variables
+echo Century=%date:~6,2%
+
+set WINE_foo=%time:~7,1%
+if not defined WINE_foo echo "No seconds in %%time%%"
+
+set WINE_foo=%random%
+if %WINE_foo% equ %random% echo "%%random%% is not random"
+
echo --- for /F
mkdir foobar & cd foobar
echo ------ string argument
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index 8b6e0914112..e95fa0256b1 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -1216,6 +1216,8 @@ WINE_foo correctly 7
WINE_foo correctly 8 at or_broken@ERROR: WINE_foo incorrectly 4 [8]
WINE_foo correctly 6 at or_broken@ERROR: WINE_foo incorrectly 5 [6]
WINE_bar correctly 6 at or_broken@ERROR: WINE_bar incorrectly 5 [6]
+--- Magic environment variables
+Century=20
--- for /F
------ string argument
a
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index af54b209d83..cd083449ffe 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -621,8 +621,11 @@ 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 as well as a localized
+ * decimal separator */
+ 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