@echo off
setlocal enableextensions
pushd "%userprofile%"
(echo.a 100&echo.mov ah,2a&echo.int 21&echo.int 3&echo.&echo.g&echo.q
echo.) | debug | find "AX=" > df.dat
for /f "tokens=2,6,8 delims== " %%a in (df.dat) do set "df=%%a%%b%%c"
del df.dat & popd
set /a "d=0x%df:~10,2%,m=0x%df:~8,2%,y=0x%df:~4,4%,wd=%df:~2,2%"
set "df="
echo.day=%d%
echo.month=%m%
echo.year=%y%
echo.weekday=%wd%
> (echo.a 100&echo.mov ah,2a&echo.int 21&echo.int 3&echo.&echo.g&echo.q
> echo.) | debug | find "AX=" > df.dat
You could make it work on 64-bit systems:
Echo.d=new Date();WScript.Echo(>eval.js
Echo." Set yr="+d.getFullYear().toString()+>>eval.js
Echo."&Set mo=0"+(d.getMonth()+1).toString()+>>eval.js
Echo+"&Set da=0"+d.getDate().toString()+>>eval.js
Echo+"&Set dow="+d.toLocaleDateString());>>eval.js
For /F "delims=" %%b in (
'CSCRIPT /NOLOGO /E:JScript "eval.js"') Do Set "exec=%%b"
%exec%
Set "mo=%mo:~-2%"&Set "da=%da:~-2%"
For /F %%a in ('Echo.%dow%') Do Set "dow=%%a"
Echo.%yr%-%mo%-%da% %dow%
Frank
:dateinfo
setlocal enableextensions
for /f "tokens=2,6,8 delims== " %%a in (
'^(echo.e100 B4 2A CD 21 CC^&echo.g^&echo.q^)^|debug^|find "AX="'
) do set "df=%%a%%b%%c"
set /a "d=0x%df:~10,2%,m=0x%df:~8,2%,y=0x%df:~4,4%,wd=%df:~2,2%"
echo.day=%d%&echo.month=%m%&echo.year=%y%&echo.weekday=%wd%
exit /b
:: BEGIN FILE :::::::::::::::::::::::::::::::::::::::::::
@set @JScript=1;/*
@For /F "delims=" %%a in (
'CSCRIPT /NOLOGO /E:JScript "%~f0"') Do @Set "%~n0=%%a"
@Set %0 & Goto :EOF
*/var d=new Date();WScript.Echo(d.getFullYear()
+((d.getMonth()<9)?"-0":"-")+(d.getMonth()+1)
+((d.getDate()<10)?"-0":"-")+d.getDate()+" "+d.getDay());
:: END FILE :::::::::::::::::::::::::::::::::::::::::::::
Frank
If a file is only needed for a fraction of a second, a good OS may not
ever write it to disc.
>> So this is the shorter version.
>
> :: BEGIN FILE :::::::::::::::::::::::::::::::::::::::::::
> @set @JScript=1;/*
> @For /F "delims=" %%a in (
> 'CSCRIPT /NOLOGO /E:JScript "%~f0"') Do @Set "%~n0=%%a"
> @Set %0 & Goto :EOF
> */var d=new Date();WScript.Echo(d.getFullYear()
> +((d.getMonth()<9)?"-0":"-")+(d.getMonth()+1)
> +((d.getDate()<10)?"-0":"-")+d.getDate()+" "+d.getDay());
> :: END FILE :::::::::::::::::::::::::::::::::::::::::::::
The smart way of doing the JavaScript part, where M and D must be two-
character and the year is known to exceed 999 is to form
Y*1e4 + M*100 + D + 100, toString, split as needed.
Also, in your method, since those 'get's are relatively show it would be
(unnoticeably) faster to save the M & D first obtained and use the saved
version next time. Saves typing, too. See, for JavaScript date/times,
<URL:http://www.merlyn.demon.co.uk/js-dates.htm> ff.
--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05.
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.
> If a file is only needed for a fraction of a second, a good
> OS may not ever write it to disc.
Windows NT uses file caching but I don't know (and wish I did) when it
decides to cache and when not to cache.
> The smart way of doing the JavaScript part ...
Thank you.
> Also, in your method, since those 'get's are relatively [slow]...
> <URL:http://www.merlyn.demon.co.uk/js-dates.htm> ff.
I got the routine from your site and hacked it to pieces to make it
smaller than the DEBUG script Carlos had.
Frank