home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
qtawkos2.zip
/
QTAUTL.ZIP
/
apptadd.exp
< prev
next >
Wrap
Text File
|
1991-05-30
|
4KB
|
134 lines
# Utility to Add Repetitive Appoints to Calender
# Input Line of Form:
#
# Start Stop Time Rept. Appointment Comments
# xx/xx/xx xx/xx/xx xx:xx weekly appointment comments --->
# daily
#
BEGIN {
stderr = "stderr";
# the following date formats would be used for U.S. style dates
t0date = sdate(0); # todays date: mm/dd/yy
t1date = sdate(1); # todays date: mm/dd/yyyy
split(t1date,tdate,/\//);
today_jdn = jdn(tdate[3],tdate[1],tdate[2]);
century = tdate[3] / 100;
tdc = /{_d}{1,2}/;
t_pattern = /{tdc}:{tdc}/;
time_pattern = /^{t_pattern}$/;
date_pattern = /{tdc}\/{tdc}\/{tdc}/;
double_date = /({date_pattern}{_w}+){2,2}/;
appt_date = /^{_w}*{date_pattern}{_w}/;
colon_s = /:/;
slash_s = /\//;
# input format
adate = /^{_w}*{double_date}{t_pattern}{_w}+/;
split(t0date,cdate,slash_s);
apptfile = "c:\\appt" ∩ cdate[3] ∩ ".dat";
tmpf = "c:\\$tmp$.tmp";
system("copy " ∩ apptfile ∩ " " ∩ tmpf);
split(stime(2),now,colon_s);
hour = 1;
minute = 2;
}
INITIAL {
if ( FILENAME == "stdin" ) {
print "Add Repeat Appointments.";
print "Input Appointments to Add.";
print "Format: (repeat == weekly/wkly/daily)";
print "start_date stop_date time repeat Appointment";
}
}
adate {
local rc, ii = $1, tac, i;
# index start date - element to stop date
split($2,tac,slash_s);
if ( tac[3] < 100 ) tac[3] += century * 100;
start_date[ii][0] = jdn(tac[3],tac[1],tac[2]);
start_date[ii][1] = $3; # index start date - element to appt. time
rc = strlwr($4) ~~ /w(ee)?kly/ ? 7 : 1;
start_date[ii][2] = rc; # index start date - element to repitition count
$1 = $2 = $3 = $4 = "";
start_date[ii][3] = $0; # index start date - appointment
}
END {
local iline, cline, sd, atim, repc, appt;
local tac, tas, i, c_cnt,c_jdn, i_jdn;
for ( s_date in start_date ) {
split(s_date,tac,slash_s);
if ( tac[3] < 100 ) tac[3] += century * 100;
sd = set_date(tac);
c_jdn = jdn(tac[3],tac[1],tac[2]);
stpd = start_date[s_date][0];
atim = start_date[s_date][1];
repc = start_date[s_date][2];
appt = start_date[s_date][3];
while ( c_cnt = fgetline(tmpf,iline) > 0 ) {
if ( iline ~~ appt_date ) {
split(iline,cline);
print cline[1];
split(cline[1],tas,slash_s);
if ( tas[3] < 100 ) tas[3] += century * 100;
i_jdn = jdn(tas[3],tas[1],tas[2]);
while ( tas[3] == tac[3] && c_jdn <= i_jdn ) {
print(sd,atim,appt);
fprint(apptfile,sd,atim,appt);
if ( !(sd = set_next(tac,stpd,repc)) ) break;
else c_jdn = jdn(tac[3],tac[1],tac[2]);
}
}
fprint(apptfile,iline);
if ( !sd ) break;
}
}
while ( fgetline(tmpf,iline) > 0 ) fprint(apptfile,iline);
system("del " ∩ tmpf);
}
# format date array passed as mm/dd/yy
# date array passed as:
# date[1] == month
# date[2] == day
# date[3] == year
function set_date(date) {
local rdate;
rdate = sprintf("%02u/%02u/%02u",date[1],date[2],(date[3] + 0) % 100);
return rdate;
}
# return date for next appointment or FALSE if past stop date
# tac passes the current date in array and returns new date in array
# tac[1] == month
# tac[2] == day
# tac[3] == year
# function return is new date as string: mm/dd/yy
function set_next(tac,stop_jdn,rept) {
local njdn;
local rdate = FALSE;
njdn = jdn(tac[3],tac[1],tac[2]) + rept;
if ( njdn <= stop_jdn ) {
tac = caln(njdn);
rotate(tac); # get proper order of month/day/year
rdate = set_date(tac);
}
return rdate;
}
# function to convert year/month/day into julian day number
#include <jdn.exp>