~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Getting the current date (DEBUG solution) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To get the date into variables without dependency on locale the simplest solution is to use a small machine code program that can get the date directly from DOS. DOS provides services that return the date in a standard form, and in fact the form it provides this data in (BCD) is trivial to convert into text. Here is the source code for the program; 2274:0180 BF0701 MOV DI,0107 2274:0183 B404 MOV AH,04 2274:0185 CD1A INT 1A 2274:0187 E80200 CALL 018C 2274:018A 89CA MOV DX,CX 2274:018C E80000 CALL 018F 2274:018F 86D6 XCHG DL,DH 2274:0191 88D0 MOV AL,DL 2274:0193 D410 AAM 10 2274:0195 0D3030 OR AX,3030 2274:0198 86C4 XCHG AL,AH 2274:019A AB STOSW 2274:019B 47 INC DI 2274:019C C3 RET I will add a walk through/description of how it works to this page in time, at the moment this page exists to present the subroutine and also so that one may compare this solution with the pure batch solution given in the article entitled "Getting the current date (reverse engineering system date format)". For now, there is a description of the %F%/%.% recursion mechanism (that you need to set up in order to use the subroutine in your programs) in the pure batch solution article. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The complete subroutine ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ::************************************************************ ::* GETDATE- GET SYSTEM DATE * ::* Entry: (No parameters required) * ::* Exit: %YH%=century %YL%=year %MM%=month %DD%=day* ::* Returned variables are 2 digits long * ::* Last Modified: 16/11/00 * ::* Compatibility: DOS 5+ (Tested: DOS 7) * ::* Notes: + Requires %F%/%.% recursion mechanism to be * ::* set up (see documentation) * ::************************************************************ :GETDATE ECHO E180 BF 07 01 B4 04 CD 1A E8 02 00 89 CA E8 00 00 86>$ ECHO E190 D6 88 D0 D4 10 0D 30 30 86 C4 AB 47 C3>>$ FOR %%_ IN (RIP 180 G W Q) DO ECHO %%_>>$ ECHO SET %%1=XX XX XX XX >$.BAT DEBUG $.BAT<$>NUL CALL $.BAT _ SET .=GOTO:GDLOP0 %F% %_% MM DD YH YL :GDLOP0 SET %5=%1 SHIFT IF NOT !%5==! GOTO GDLOP0 SET _= FOR %%_ IN ($ $.BAT) DO DEL %%_ %RET% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A working example ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Invoke this batch program with no parameters; PROGNAME When it returns type SET to see that the variables %YH%, %YL%, %MM%, %DD% are set with the current system date. The GETDATE subroutine has been used in this program but has been "integrated" into it to make it more compact. Notice how this program is functionally equivalent to the one documented in "Getting the current date (reverse engineering system date format)" but only one quarter of the size; a little machine code often goes a long way! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @ECHO OFF %.% ECHO E180 BF 07 01 B4 04 CD 1A E8 02 00 89 CA E8 00 00 86>$ ECHO E190 D6 88 D0 D4 10 0D 30 30 86 C4 AB 47 C3>>$ FOR %%_ IN (RIP 180 G W Q) DO ECHO %%_>>$ ECHO SET %%1=XX XX XX XX >$.BAT DEBUG $.BAT<$>NUL CALL $.BAT _ SET .=GOTO:GDLOP0 %0 %_% MM DD YH YL :GDLOP0 SET %5=%1 SHIFT IF NOT !%5==! GOTO GDLOP0 FOR %%_ IN (. _) DO SET %%_= FOR %%_ IN ($ $.BAT) DO DEL %%_ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~