Subj : ... To : All From : Robert Todd Date : Thu Dec 07 2000 01:53 am FORUM: (104) comp.lang.pascal.borland MSG#: 14132 FROM: NAT.MEAD@NTLWORLD.COM DATE: 22 Nov 2000, 12:11p TO: ALL SUBJECT: source - datetime - promised someone this { source - datetime.pas this is the date/time funcs i promised someone. uses dos calls for the lot, also has boot_drive; func and dos_ver func; has example usage at the bottom. why use dos calls and not get info from cmos? cos of daylight saving and crap like that. by using.. day; dddd; l_mmmm; yyyy; you get.. Wednesday the 22nd of November 2000 whereas you'd normaly only get 22/11/2000 (can do that too ofcourse) Code^Bandit. --do as you will, but dont be lame. } uses dos; type string5 = string[5]; string3 = string[3]; string2 = string[2]; string11= string[11]; var regs : registers; function Int2Str(I: Longint): String11; var S: string11; begin Str(I, S); {absolutly no error checking... , so what!} Int2Str := S; end; function dos_ver:string11; begin regs.ah:=$30; intr($21,regs); dos_ver:=int2str(regs.al)+'.'+int2str(regs.ah); end; function boot_drive:char; {drive you booted from} begin regs.ax:=$3305; intr($21,regs); boot_drive:=chr(regs.dl+64); {see!, im not always lazy coder!} {(only cos ascii chart is to hand)} end; function day:string11; {sunday..saturday} const days : array[0..6] of string=('Sunday','Monday','Tuesday','Wednesday', 'Thursday','Friday','Saturday'); begin regs.ah:=$2A; intr($21,regs); day:=days[regs.al]; end; function shortday:string5; {sun..sat} const days : array[0..6] of string=('Sun','Mon','Tues','Wed', 'Thur','Fri','Sat'); begin regs.ah:=$2A; intr($21,regs); shortday:=days[regs.al]; end; function dd:byte; {1..31} begin regs.ah:=$2A; intr($21,regs); dd:=regs.dl; end; function dddd:string5; {1st..31st} var sb : byte; begin regs.ah:=$2A; intr($21,regs); sb:=regs.dl; if sb in [1,2,3,21,22,23,31] then case sb of 1,21,31 : dddd:=int2str(sb)+'st'; 2,22 : dddd:=int2str(sb)+'nd'; 3,23 : dddd:=int2str(sb)+'rd'; end else dddd:=int2str(sb)+'th'; end; function mm:byte; {1..12} begin regs.ah:=$2A; intr($21,regs); mm:=regs.dh; end; function mmmm:string5; {jan..dec} const months : array[1..12] of string=('Jan','Feb','Mar','Apr','May','Jun', 'Jul','Aug','Sep','Oct','Nov','Dec'); begin regs.ah:=$2A; intr($21,regs); mmmm:=months[regs.dh]; end; function l_mmmm:string11; {january..december} const months : array[1..12] of string=('January','Febuary','March','April','May','June', 'July','August','September','October','November','December'); begin regs.ah:=$2A; intr($21,regs); l_mmmm:=months[regs.dh]; end; function yyyy:longint; {1999..2000 etc} begin regs.ah:=$2A; intr($21,regs); yyyy:=regs.cx; end; function yy:string2; {99..00 etc} begin regs.ah:=$2A; intr($21,regs); yy:=copy(int2str(regs.cx),3,2); end; function hour:string2; var tmp : string3; begin regs.ah:=$2c; intr($21,regs); tmp:=int2str(regs.ch); if length(tmp) < 2 then tmp:='0'+tmp; hour:=tmp; end; function minutes:string2; var tmp : string3; begin regs.ah:=$2c; intr($21,regs); tmp:=int2str(regs.cl); if length(tmp) < 2 then tmp:='0'+tmp; minutes:=tmp; end; function seconds:string2; var tmp : string3; begin regs.ah:=$2c; intr($21,regs); tmp:=int2str(regs.dh); if length(tmp) < 2 then tmp:='0'+tmp; seconds:=tmp; end; function sec100:byte; begin regs.ah:=$2c; intr($21,regs); sec100:=regs.dl; end; begin writeln('booted from ',boot_drive); writeln('dos ver ',dos_ver); writeln('time ',hour,':',minutes,'.',sec100); writeln('date ',day,' the ',dddd,' of ',l_mmmm,' ',yyyy); readln; end. .... Platinum Xpress & Wildcat!..... Nice!!!! --- Platinum Xpress/Win/WINServer v3.0pr5 * Origin: Fido/3407 - MS Online - msol.dtdns.net (1:3407/4) .