home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.wwiv.com
/
ftp.wwiv.com.zip
/
ftp.wwiv.com
/
pub
/
UTILITY
/
USTATV20.ARJ
/
CLCKSTFF.PRO
next >
Wrap
Text File
|
1989-01-09
|
3KB
|
190 lines
function tch ( i : str) : str;
{ Pads digits with leading 0 if neccessary }
begin
if length (i) > 2
then
i := copy (i, length (i) - 1, 2)
else
if length (i) = 1
then
i := '0' + i;
tch := i;
end;
function time:str;
{ Returns the current time as a string HH:MM:SS }
var
reg : regs;
h,
m,
s : string [4];
begin
reg.ax := $2c00;
intr ($21, reg);
str (reg.cx shr 8, h);
str (reg.cx mod 256, m);
str (reg.dx shr 8, s);
time := tch (h) + ':' + tch (m) + ':' + tch(s);
end;
function date : str;
var
reg : regs;
m,
d,
y : string[4];
begin
reg.ax := $2a00;
msdos (reg);
str (reg.cx, y);
str (reg.dx mod 256, d);
str (reg.dx shr 8, m);
date := tch (m) + '/' + tch (d) + '/' + tch(y);
end;
function value (I : str):integer;
var
n,
n1 : integer;
begin
val (i, n, n1);
if n1 <> 0
then
begin
i := copy (i, 1, n1-1);
val (i, n, n1)
end;
value := n;
if i = ''
then
value := 0;
end;
function cstr (i:integer):str;
var
c : str;
begin
str (i, c);
cstr := c;
end;
function leapyear (yr:integer):boolean;
begin
leapyear := (yr mod 4 = 0) and ((yr mod 100 <> 0) or
(yr mod 400 = 0));
end;
function days (mo, yr : integer):integer;
var
d : integer;
begin
d := value (copy ('312831303130313130313031', 1 + (mo-1) * 2, 2));
if (mo = 2) and leapyear (yr)
then
d := d + 1;
days := d;
end;
function daycount (mo, yr : integer) : integer;
var
m, t : integer;
begin
t := 0;
for m := 1 to (mo - 1) do
t := t + days (m, yr);
daycount := t;
end;
function daynum(dt:str):integer;
var
d,
m,
y,
t,
c : integer;
begin
t := 0;
m := value (copy (dt, 1, 2));
d := value (copy (dt, 4, 2));
y := value (copy (dt, 7, 2)) + 1900;
for c := 1985 to y - 1 do
if leapyear (c)
then
t := t + 366
else
t := t + 365;
t := t + daycount (m, y) + (d - 1);
daynum := t;
if y < 1985
then
daynum := 0;
end;
function dat:str;
var
ap,
x,
y : str;
i : integer;
begin
case daynum (date) mod 7 of
0: x:= 'Tue';
1: x:= 'Wed';
2: x:= 'Thu';
3: x:= 'Fri';
4: x:= 'Sat';
5: x:= 'Sun';
6: x:= 'Mon';
end;
case value (copy (date, 1, 2)) of
1: y:= 'Jan';
2: y:= 'Feb';
3: y:='Mar';
4: y:='Apr';
5: y:='May';
6: y:='Jun';
7: y:='Jul';
8: y:='Aug';
9: y:='Sep';
10: y:='Oct';
11: y:='Nov';
12: y:='Dec';
end;
x := x + ' ' + y + ' ' + copy (date, 4, 2) + ', ' + cstr (1900
+ value (copy (date, 7, 2)));
y := time;
i := value (copy (y, 1, 2));
if i > 11
then
ap := 'pm'
else
ap := 'am';
if i > 12
then
i := i - 12;
if i = 0
then
i := 12;
dat := cstr (i) + copy (y, 3, 3) + ' ' + ap + ' ' + x;
end;