home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / qtawkos2.zip / QTAUTL.ZIP / apptdis.exp < prev    next >
Text File  |  1991-05-30  |  4KB  |  132 lines

  1. # QTAwk utility to set alarm clock for next appointment time
  2. # appointments stored in file "appoint.fle" in format:
  3. #
  4. # mm/dd/yy hh:mm appointment comments/description/place
  5. # or
  6. # mm/dd/yyyy hh:mm appointment comments/description/place
  7. #
  8. # the file "appoint.fle" is read until an appointment if found for today
  9. # for which the appointment hour is equal to the current hour and
  10. # the appointment minute is greater than the current minute
  11. # or
  12. # the appointment hour is greater than the current hour
  13. # An informative message is issued about the time set for the
  14. # appointment, and the program to set the alarm is invoked.
  15. # Any appointment comments are displayed
  16. # Times are military times ( 0 <= hh < 24 )
  17. #
  18. BEGIN {
  19.     stderr = "stderr";
  20.     if ( ARGC > 1 ) {
  21.     fprintf(stderr,"Incorrect Invocation.\nUsage: QTAwk -ftclk.exp\n");
  22.     exit;
  23.     }
  24.  
  25. # the following date formats would be used for U.S. style dates
  26.     t0date = sdate(0);       # todays date: mm/dd/yy
  27.     t1date = sdate(1);       # todays date: mm/dd/yyyy
  28.  
  29.     split(t1date,tdate,/\//);
  30.     today_jdn = jdn(tdate[3],tdate[1],tdate[2]);
  31.  
  32.     # special date
  33.     special_date = "08/31/1996";
  34.     split(special_date,spldate,/\//);
  35.     spl_date_jdn = jdn(spldate[3],spldate[1],spldate[2]);
  36.     days_rem = spl_date_jdn - today_jdn;
  37.     spl_day = (spl_date_jdn + 1) % 7;
  38.     last_week = spl_day ? 1 : 0;
  39.  
  40. # use following to allow more variation in date format
  41.     today = /^{_w}*({t0date}|{t1date}){_w}/;
  42.  
  43. # the following date formats would be used for European style dates
  44. #    t2date = sdate(2);     # todays date: dd/mm/yy
  45. #    t3date = sdate(3);     # todays date: dd/mm/yyyy
  46. # use following to allow more variation in date format
  47. #    today = /^{_w}*({t2date}|{t3date}){_w}/;
  48.  
  49.     time_pattern = /^[0-9]?[0-9]:[0-9][0-9]?$/;
  50.  
  51.     colon_s = /:/;
  52.     slash_s = /\//;
  53.  
  54.     split(t0date,cdate,slash_s);
  55.     ARGV[ARGC++] = "c:\\appt" ∩ cdate[3] ∩ ".dat";
  56.  
  57.     split(stime(2),now,colon_s);
  58.  
  59.     hour = 1;
  60.     minute = 2;
  61.  
  62.     appt_set = FALSE; # appointment set flag
  63.  
  64.     notice_hr = 00; # set time for notices == 00:00
  65.  
  66.     l1_hdr = ".======== " ∩ t1date ∩ " ========.";
  67.     l2_hdr = ".==================.";
  68.     spl_hdr = "*> " ∩ t1date ∩ " <> " ∩ special_date ∩ " <";
  69.     print l1_hdr;
  70.     print "Appointments: " ∩ t0date;
  71.     print " Time\tPurpose";
  72.     print ".---.\t.----------->";
  73.  
  74.     lunch_time = "11:30";   # lunch
  75.     split(lunch_time,lunch,colon_s);
  76.  
  77.     cob_time = "16:05";     # close of business
  78.     split(cob_time,cob,colon_s);
  79.  
  80.     if ( now[hour] <  lunch[hour] ||
  81.     (now[hour] == lunch[hour] && now[minute] < lunch[minute]) ) {
  82.     appt_list[lunch_time] = "Lunch Time";
  83.     }
  84.  
  85.     if ( now[hour] <  cob[hour] ||
  86.     (now[hour] == cob[hour] && now[minute] < cob[minute]) ) {
  87.     appt_list[cob_time] = "Closing Time";
  88.     }
  89. }
  90.  
  91. # find only those lines with todays date to set appointments
  92. # use following to allow more variation in date format
  93. today {  # find records for today
  94.     local atime, ai, apt_time;
  95.  
  96.     if ( $2 ~~ time_pattern ) {
  97.     split($2,atime,colon_s);
  98.     if ( atime[hour] == notice_hr &&
  99.          atime[minute] == 0 ) {
  100.         $1 = $2 = "";
  101.         notice[n_cnt++] = strim($0,TRUE,FALSE);
  102.         appt_set = TRUE;
  103.     } else if ( atime[hour] >  now[hour] ||
  104.            (atime[hour] == now[hour] && atime[minute] > now[minute]) ) {
  105.         appt_time = $2;
  106.         $1 = $2 = "";
  107.         appt_list[appt_time] = strim($0,TRUE,FALSE);
  108.         appt_set = TRUE;
  109.     }
  110.     }
  111.     next;
  112. }
  113.  
  114.     {
  115.     if ( appt_set ) exit;
  116. }
  117.  
  118. END {
  119.     for ( appt_time in notice     ) printf("NOTICE\t%s\n",notice[appt_time]);
  120.     for ( appt_time in appt_list ) printf("%s\t%s\n",appt_time,appt_list[appt_time]);
  121. #    print l1_hdr;
  122.     print spl_hdr;
  123.     remg = "\tRemaining";
  124.     print "*\tDays: " ∩ days_rem ∩ remg;
  125.     print "*\tWeeks: " ∩ ((days_rem - spl_day)/7 + last_week) ∩ remg;
  126.     print "*\tMonths: " ∩ days_rem/30 ∩ remg;
  127.     print spl_hdr;
  128. }
  129.  
  130. # function to convert year/month/day into julian day number
  131. #include <jdn.exp>
  132.