home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Tools - Objects / Virtual User 1.0b5 / Example Libraries / TimeLib.vu < prev   
Encoding:
Text File  |  1990-10-05  |  1.6 KB  |  57 lines  |  [TEXT/MPS ]

  1. #
  2. #    File:        Time.vu
  3. #
  4. #    Contains:    Tasks that make it easier to work with time in VU.
  5. #
  6. #    Written by:    Sean Flynn
  7. #
  8. #    Copyright:    © 1990 by Apple Computer, Inc., all rights reserved.
  9. #
  10. #
  11. #
  12.  
  13.  
  14. # *****************************************************************************************
  15. task wait_for_time( end_hour := 0, end_minute := 0, end_second := 0 )
  16. # Wait_for_time task.  Wait until a specified time of day.
  17. begin
  18.     while match[time h:?h2 s:?s2] and
  19.             ( h2 / 100 <> end_hour  or
  20.               h2 mod 100 < end_minute or
  21.               s2 < end_second ) do;
  22. end;
  23.  
  24.  
  25. # *****************************************************************************************
  26. task print_current_time(print_date := true) begin
  27. # This task pretty prints the current time.  The format is as follows:
  28. #        <hour of day>:<minutes>:<seconds> <AM or PM>
  29. # It also takes one parameter that indicates whether the date should be printed.
  30. # If the actual parameter passed is a true value, the current date is also printed.
  31. # If no parameter is passed, the date is printed by default.
  32. # The format of the date is as follows:
  33. #        <month>/<day>/<year>
  34. #
  35.     match [time h:?hour s:?secs d:?day m:?month y:?year];
  36.     hour_of_day := hour / 100;
  37.     if(hour < 1200) begin # in AM
  38.         if(hour_of_day) print hour_of_day;
  39.         else print '12';
  40.         meridian := ' AM';
  41.     end;
  42.     else begin # in PM
  43.         if hour_of_day = 12 print hour_of_day;
  44.         else print hour_of_day - 12;
  45.         meridian := ' PM';
  46.     end;
  47.     print ':',(hour mod 100) / 10,(hour mod 10),':',secs;
  48.     print meridian;
  49.     if(print_date) begin
  50.         print " ",month,"/",day,"/",(year mod 100) / 10,(year mod 10);
  51.     end;
  52. end;
  53.  
  54.  
  55. (* Example Usage:
  56.     print_current_time(true);
  57. *)