Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Date functions without date variable

3 views
Skip to first unread message
Message has been deleted
Message has been deleted

carlos

unread,
Nov 22, 2009, 12:04:19 AM11/22/09
to
full condensed:

@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%

Frank P. Westlake

unread,
Nov 22, 2009, 1:49:09 AM11/22/09
to
"carlos"
news:23d5c13a-d083-4b75...@g23g2000yqh.googlegroups.com...

> (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


carlos

unread,
Nov 22, 2009, 6:49:28 AM11/22/09
to
I was thinking how to do it all without writing a file to make it
faster and shorter. So this is the shorter version.

: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


Frank P. Westlake

unread,
Nov 22, 2009, 2:29:31 PM11/22/09
to
"carlos"
news:d09117b8-0170-43a4...@c3g2000yqd.googlegroups.com...

>I was thinking how to do it all without writing a file to make it
> faster and shorter. 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 :::::::::::::::::::::::::::::::::::::::::::::

Frank


Message has been deleted

Dr J R Stockton

unread,
Nov 23, 2009, 1:18:12 PM11/23/09
to
In alt.msdos.batch.nt message <hec3et$7uq$1...@news.albasani.net>, Sun, 22
Nov 2009 11:29:31, Frank P. Westlake <frank.w...@yahoo.com> posted:

>"carlos"
>news:d09117b8-0170-43a4...@c3g2000yqd.googlegroups.com...
>>I was thinking how to do it all without writing a file to make it
>> faster and shorter.

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.

Frank P. Westlake

unread,
Nov 23, 2009, 2:29:00 PM11/23/09
to
"Dr J R Stockton"
news:UslBlXgk...@invalid.uk.co.demon.merlyn.invalid...

> 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


0 new messages