{$M 1024, 0, 0} program CLOKCHEK { For autoexec.bat; to see that date and time are plausible, by comparison with those of the previous call of CLOKCHEK } ; uses Dos ; function MJD(const Y : word ; const M, D : byte) : longint { Valid 1897/03/01 to 2100/02/28 inclusive ONLY ; the extension back to 1897 happens because the argument of "div" goes negative. } ; const MonthStarts : array [1..12] of word = { Jan+Feb into previous year } (15384,15415,15078,15109,15139,15170,15200,15231,15262,15292,15323,15353) ; { Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec } begin MJD := ((longint(Y)-1900-Ord(M<3))*1461) div 4 + MonthStarts[M] + D ; end { Derived from JPC by JRS; "optimised" for integers } ; var Yr, Mo, Dy, DW, Hr, Mn, Sc, Cs : word ; Par : string [30] ; F : file ; SR : SearchRec ; XX, MJSecsN, MJSecsW : longint ; J : integer ; const FN = '\CLOKCHEK.DAT' ; Flag : boolean = false ; MaxSince : longint = 36*longint(3600) ; procedure Oh(const S : string) ; begin Flag := true ; Writeln(^G^G^G'WARNING : ', S) end {Oh} ; function MJS(const S : string) : longint ; var T : longint ; const DS = 'SunMonTueWedThuFriSat' ; begin T := (((MJD(Yr, Mo, Dy)-50000)*24 + Hr)*60 + Mn)*60 + Sc ; Writeln(S, Yr:5, Mo:3, Dy:3, Hr:4, Mn:3, Sc:3, ' ; ', T:12, ' s', Copy(DS, Succ(DW*3), 3):5) ; MJS := T end {MJS} ; BEGIN Writeln('CLOKCHEK 1997-10-24 jrs :') ; GetTime(Hr, Mn, Sc, Cs) ; GetDate(Yr, Mo, Dy, DW) ; MJSecsN := MJS('Now') ; FindFirst(FN, AnyFile, SR) ; if DosError>0 then begin Writeln('No '+FN+'!') ; MJSecsW := 0 end {} else with SR do begin Sc := (Time and $1F)*2 ; Time := Time shr 5 ; Mn := Time and $3F ; Time := Time shr 6 ; Hr := Time and $1F ; Time := Time shr 5 ; Dy := Time and $1F ; Time := Time shr 5 ; Mo := Time and $0F ; Time := Time shr 4 ; Yr := Time + 1980 ; DW := (MJD(Yr, Mo, Dy) +3) mod 7 ; MJSecsW := MJS('Was') ; end ; Par := ParamStr(1) ; Val(Par, XX, J) ; if J=0 then MaxSince := XX else if Par='/w' then MaxSince := 86400*2*Ord(DW=1) + 86400 + 3600 else if Par='/?' then begin Writeln('CLOKCHEK, CLOKCHEK /w, CLOKCHEK seconds') ; HALT ; end else if Par>'' then Oh('Parameter error') ; Writeln('MaxSince ', MaxSince:6, #127' = ':16, MJSecsN-MJSecsW:8, ' s') ; Assign(F, FN) ; ReWrite(F) ; Close(F) ; if MJSecsW>=MJSecsN then Oh('Was>=Now') ; if MJSecsW ') ; Readln ; {$ENDIF} END. www.merlyn.demon.co.uk Insufficiently tested as yet. If the difference between the current DateTime and the DateTime when this was last run is not plausible, it invites correction; try it in AUTOEXEC.BAT. MinSince = 1 second MaxSince = 1.5 days, or Parameter in seconds, or if Parameter is /w then 1 hour + 1 day , or + 3 days if it is Monday.