home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / os / vms / 20802 < prev    next >
Encoding:
Internet Message Format  |  1993-01-12  |  3.9 KB

  1. Path: sparky!uunet!gatech!concert!ais.com!bruce
  2. From: bruce@ais.com (Bruce C. Wright)
  3. Newsgroups: comp.os.vms
  4. Subject: Re: Implimenting "TOMORROW +1: 0:0" from an .EXE
  5. Message-ID: <1993Jan12.123223.5937@ais.com>
  6. Date: 12 Jan 93 12:32:23 GMT
  7. References: <1993Jan11.153438.28624@magnus.acs.ohio-state.edu> <11JAN199319201213@spades.aces.com>
  8. Organization: Applied Information Systems, Chapel Hill, NC
  9. Lines: 71
  10.  
  11. In article <11JAN199319201213@spades.aces.com>, gavron@spades.aces.com (Ehud Gavron 602-570-2000 x. 2546) writes:
  12. > In article <1993Jan11.153438.28624@magnus.acs.ohio-state.edu>, pat@magnus.acs.ohio-state.edu (Patrick E Plaisted) writes...
  13. > #I have the need to set an AST timer queue entry to fire at, in DCL
  14. > #syntax, "TOMORROW +1:0:0".  I've looked through all the LIB$ routines,
  15. > #as well as $bintim and $asctim.  Is there a simple way to get a
  16. > #quadword time value set to this so I can stick it into $setimr?  
  17. > #My only thoughts on how to do this are:   
  18. > # 
  19. > #  1. calculate the number of hours to midnight.
  20. > #  2. calculate the number of minutes to midnight.
  21. > #  3. calculate the number of seconds to midnight.
  22. > #  4. use lib$cvt_to_internal_time to convert these values to
  23. > #     delta time quadwords.
  24. > #  5. use lib$add_times to add these values to a quadword containing the 
  25. > #     current time.
  26. > #  6. again using lib$add_times, add 1 hour to this value.
  27. > #  7. finally, call $setimr with the quadword.
  28. > # 
  29. > #I think this approach should work, but am I missing something really 
  30. > #obvious?  Is there an easier way to do this?
  31. >     1. Call SYS$GETTIM to get current time in ticks (10ns units)
  32. >     2. Add 144,000,000 to this number 
  33. >        24 hrs x 60 min  x 60 sec  x 100000 ns    144,000,000 ns/day
  34. >                  -----     -----         ---- =
  35. >                hr        min          sec
  36. >     3. Use SYS$ASCTIM to get this in ascii format in the form
  37. >        DD-MMM-YYYY HH:MM:SS.hh
  38. >     4. Insert in the 13th position of the string "01:00:00.00"
  39. >     5. Call SYS$BINTIM
  40. >     (I may be off on the number in #2 but it looks right.  I'm
  41. >      sure someone will rush to correct me if it isn't.)
  42.  
  43. Sorry, Ehud.  It isn't.  The number you compute (144,000,000) is only
  44. equivalent to 14.4 seconds :).  You only multiplied in one of the 60's
  45. and used the wrong multiplier to convert from seconds to 100's of
  46. nanoseconds (which should be 10,000,000, not 100,000).  The correct
  47. number is 864,000,000,000.  Naturally this won't fit into a longword;
  48. the largest time that can is about 7 minutes as I recall.  You'll want
  49. to use the quadword math routines to do it in a reasonably easy-to-read
  50. way (and you'll have to for the addition to the system binary time as
  51. well).
  52.  
  53. Alternatively, you could take advantage of the fact that the VMS time
  54. starts at midnight on 17-NOV-1858, so that midnight always falls on
  55. values that are modulo 864,000,000,000 (I believe VMS ignores the leap
  56. seconds that are sometimes inserted, although this wouldn't matter for
  57. most applications), and compute the time as follows:
  58.  
  59.     1.  Get the current time using $gettim.  (Or, to compute the
  60.         offset from a specific time, convert a string with that
  61.         time using $bintim).
  62.     2.  Add 864,000,000,000 to the current time.
  63.     3.  Compute the remainder of this value with 864,000,000,000.
  64.     4.  Subtract the remainder from the value computed in step 2.
  65.     5.  Add the number of 100's of nanoseconds in one hour to the
  66.         result computed in step 4.  (This number can be computed
  67.         as 60*60*10,000,000, or 36,000,000,000;  as noted above
  68.         all of these steps will require quadword math).
  69.     6.  If you want the result in a printable format, feed this
  70.         number to $asctim.
  71.  
  72. This avoids multiple conversions to and from string (printable) format,
  73. but I'm not sure that it's any nicer than the first algorithm presented.
  74. It would be convenient if one of the VMS libraries or system services
  75. allowed such a specification to be given to some $bintim-like routine,
  76. but I'm unaware of any such service if it exists.
  77.  
  78. Bruce C. Wright
  79.