home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / os / vms / 20813 < prev    next >
Encoding:
Text File  |  1993-01-12  |  4.8 KB  |  127 lines

  1. Path: sparky!uunet!haven.umd.edu!decuac!pa.dec.com!engage.pko.dec.com!e2big.mko.dec.com!nntpd.lkg.dec.com!sousa.tay.dec.com!keptin.enet.dec.com
  2. From: granoff@keptin.enet.dec.com (Mark H. Granoff)
  3. Newsgroups: comp.os.vms
  4. Subject: Re: Implimenting "TOMORROW +1: 0:0" from an .EXE
  5. Message-ID: <2382@sousa.tay.dec.com>
  6. Date: 12 Jan 93 13:39:56 GMT
  7. References: <1993Jan11.153438.28624@magnus.acs.ohio-state.edu> <11JAN199319201213@spades.aces.com>
  8. Sender: newsa@sousa.tay.dec.com
  9. Reply-To: granoff@ranger.enet.dec.com
  10. Organization: Digital Equipment Corporation, Littleton, MA
  11. Lines: 114
  12.  
  13.  
  14. In article pat@magnus.acs.ohio-state.edu (Patrick E Plaisted) writes...
  15. >I have the need to set an AST timer queue entry to fire at, in DCL
  16. >syntax, "TOMORROW +1:0:0".  I've looked through all the LIB$ routines,
  17. >as well as $bintim and $asctim.  Is there a simple way to get a
  18. >quadword time value set to this so I can stick it into $setimr?  
  19. >My only thoughts on how to do this are:   
  20. >  1. calculate the number of hours to midnight.
  21. >  2. calculate the number of minutes to midnight.
  22. >  3. calculate the number of seconds to midnight.
  23. >  4. use lib$cvt_to_internal_time to convert these values to
  24. >     delta time quadwords.
  25. >  5. use lib$add_times to add these values to a quadword containing the 
  26. >     current time.
  27. >  6. again using lib$add_times, add 1 hour to this value.
  28. >  7. finally, call $setimr with the quadword.
  29. >I think this approach should work, but am I missing something really 
  30. >obvious?  Is there an easier way to do this?
  31.  
  32. No need to bother with lengthy, error-prone calculations! VMS has it now. :-)
  33. Attached is a C program from which you can figure out what you want to do.
  34.  
  35. Basically, you can call LIB$CONVERT_DATE_STRING to convert the string
  36. "TOMORROW" to quadword time format.  Similarly, you can call SYS$BINTIM to
  37. convert a string containing a delta time (like "0 1:00:00.00") to quadword time
  38. format.  And finally, you can call LIB$ADD_TIMES to add the two together.  The
  39. result is suitable for use in SYS$SETIMR.
  40.  
  41. As an added bonus, there are some other time manipulations in here, too. 
  42. Enjoy.
  43.  
  44. Disclaimer: This program is provided AS IS, as a demonstration program only.
  45. Neither I nor Digital Equipment Corporation assume any responsibility or
  46. liability for use of this program.
  47.  
  48. /*     
  49. **  time_test.c
  50. **
  51. **  Modification History
  52. **  Date    Who        Description
  53. **  ----------- --------------- --------------------------------------------
  54. **  28 Dec 1989 M. Granoff    Author
  55. **
  56. **  Demonstrate converting time and date strings to internal values and vice
  57. **  versa.
  58. */
  59.  
  60. #include <stdio>
  61. #include <descrip>
  62.  
  63. /*
  64. **  Global Variables
  65. */
  66.  
  67. static char *day_name[8] = {"","Monday","Tuesday","Wednesday",
  68.                             "Thursday","Friday","Saturday","Sunday"};
  69.  
  70. /*     
  71. **  External Declarations
  72. */     
  73.  
  74. extern int  lib$convert_date_string(), lib$day_of_week(), sys$asctim(), 
  75.             sys$bintim(), lib$add_times();
  76.  
  77. main() {
  78.     $DESCRIPTOR (ascii_time, "XX-XXX-XXXX 00:00:00.00"); /* Filler */
  79.     int        ascii_time_len;
  80.     int        day_number;
  81.     /* Flags for convert_date_string; default all time fields and the year */
  82.     int        flags = 121;
  83.     int        internal_time[2];
  84.     int        next_day_time[2];
  85.     $DESCRIPTOR (one_day, "1 00:00:00.00");
  86.     int        one_day_delta[2];
  87.     $DESCRIPTOR (string_date, "TODAY");
  88.     int        sts;
  89.  
  90.     sts = lib$convert_date_string(&string_date, &internal_time, 0, 
  91.                                   &flags, 0, 0);
  92.     printf("Status of lib$convert_date_string call was %%x%X\n",sts);
  93.  
  94.     sts = lib$day_of_week(&internal_time, &day_number);
  95.     printf("Status of lib$day_of_week call was %%x%X\n",sts);
  96.     printf("The date %s is a %s\n", string_date.dsc$a_pointer, 
  97.                                     day_name[day_number]);
  98.  
  99.     sts = sys$asctim(&ascii_time_len, &ascii_time, &internal_time, 0);
  100.     printf("Status of sys$asctim call was %%x%X\n",sts);
  101.     printf("ASCII time is %.*s\n",ascii_time,ascii_time_len);
  102.  
  103.     sts = sys$bintim(&one_day, &one_day_delta);
  104.     printf("Status of sys$bintim call was %%x%X\n",sts);
  105.  
  106.     sts = lib$add_times(&internal_time, &one_day_delta, &next_day_time);
  107.     printf("Status of lib$add_times call was %%x%X\n",sts);
  108.  
  109.     sts = sys$asctim(&ascii_time_len, &ascii_time, &next_day_time, 0);
  110.     printf("Status of sys$asctim call was %%x%X\n",sts);
  111.     printf("The next day is %.*s\n",ascii_time,ascii_time_len);
  112.  
  113. }
  114.  
  115.  
  116. --
  117. Mark H. Granoff | Personal Computing Systems Network S/W Development Group  
  118. ---------------------------------------------------------------------------
  119. Digital Equipment Corporation | Internet: granoff@keptin.enet.dec.com
  120. 30 Porter Road, LJO2/I4       | Usenet  : ...!decwrl!keptin.enet!granoff
  121. Littleton, MA 01460           | AT&T    : +1 508 486 2090
  122. ---------------------------------------------------------------------------
  123. Opinions herein are my own and do not necessarily reflect those of Digital.
  124.  
  125.