home *** CD-ROM | disk | FTP | other *** search
- 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
- From: granoff@keptin.enet.dec.com (Mark H. Granoff)
- Newsgroups: comp.os.vms
- Subject: Re: Implimenting "TOMORROW +1: 0:0" from an .EXE
- Message-ID: <2382@sousa.tay.dec.com>
- Date: 12 Jan 93 13:39:56 GMT
- References: <1993Jan11.153438.28624@magnus.acs.ohio-state.edu> <11JAN199319201213@spades.aces.com>
- Sender: newsa@sousa.tay.dec.com
- Reply-To: granoff@ranger.enet.dec.com
- Organization: Digital Equipment Corporation, Littleton, MA
- Lines: 114
-
-
- In article pat@magnus.acs.ohio-state.edu (Patrick E Plaisted) writes...
- >I have the need to set an AST timer queue entry to fire at, in DCL
- >syntax, "TOMORROW +1:0:0". I've looked through all the LIB$ routines,
- >as well as $bintim and $asctim. Is there a simple way to get a
- >quadword time value set to this so I can stick it into $setimr?
- >My only thoughts on how to do this are:
- >
- > 1. calculate the number of hours to midnight.
- > 2. calculate the number of minutes to midnight.
- > 3. calculate the number of seconds to midnight.
- > 4. use lib$cvt_to_internal_time to convert these values to
- > delta time quadwords.
- > 5. use lib$add_times to add these values to a quadword containing the
- > current time.
- > 6. again using lib$add_times, add 1 hour to this value.
- > 7. finally, call $setimr with the quadword.
- >
- >I think this approach should work, but am I missing something really
- >obvious? Is there an easier way to do this?
-
- No need to bother with lengthy, error-prone calculations! VMS has it now. :-)
- Attached is a C program from which you can figure out what you want to do.
-
- Basically, you can call LIB$CONVERT_DATE_STRING to convert the string
- "TOMORROW" to quadword time format. Similarly, you can call SYS$BINTIM to
- convert a string containing a delta time (like "0 1:00:00.00") to quadword time
- format. And finally, you can call LIB$ADD_TIMES to add the two together. The
- result is suitable for use in SYS$SETIMR.
-
- As an added bonus, there are some other time manipulations in here, too.
- Enjoy.
-
- Disclaimer: This program is provided AS IS, as a demonstration program only.
- Neither I nor Digital Equipment Corporation assume any responsibility or
- liability for use of this program.
-
- /*
- ** time_test.c
- **
- ** Modification History
- ** Date Who Description
- ** ----------- --------------- --------------------------------------------
- ** 28 Dec 1989 M. Granoff Author
- **
- ** Demonstrate converting time and date strings to internal values and vice
- ** versa.
- */
-
- #include <stdio>
- #include <descrip>
-
- /*
- ** Global Variables
- */
-
- static char *day_name[8] = {"","Monday","Tuesday","Wednesday",
- "Thursday","Friday","Saturday","Sunday"};
-
- /*
- ** External Declarations
- */
-
- extern int lib$convert_date_string(), lib$day_of_week(), sys$asctim(),
- sys$bintim(), lib$add_times();
-
- main() {
- $DESCRIPTOR (ascii_time, "XX-XXX-XXXX 00:00:00.00"); /* Filler */
- int ascii_time_len;
- int day_number;
- /* Flags for convert_date_string; default all time fields and the year */
- int flags = 121;
- int internal_time[2];
- int next_day_time[2];
- $DESCRIPTOR (one_day, "1 00:00:00.00");
- int one_day_delta[2];
- $DESCRIPTOR (string_date, "TODAY");
- int sts;
-
- sts = lib$convert_date_string(&string_date, &internal_time, 0,
- &flags, 0, 0);
- printf("Status of lib$convert_date_string call was %%x%X\n",sts);
-
- sts = lib$day_of_week(&internal_time, &day_number);
- printf("Status of lib$day_of_week call was %%x%X\n",sts);
- printf("The date %s is a %s\n", string_date.dsc$a_pointer,
- day_name[day_number]);
-
- sts = sys$asctim(&ascii_time_len, &ascii_time, &internal_time, 0);
- printf("Status of sys$asctim call was %%x%X\n",sts);
- printf("ASCII time is %.*s\n",ascii_time,ascii_time_len);
-
- sts = sys$bintim(&one_day, &one_day_delta);
- printf("Status of sys$bintim call was %%x%X\n",sts);
-
- sts = lib$add_times(&internal_time, &one_day_delta, &next_day_time);
- printf("Status of lib$add_times call was %%x%X\n",sts);
-
- sts = sys$asctim(&ascii_time_len, &ascii_time, &next_day_time, 0);
- printf("Status of sys$asctim call was %%x%X\n",sts);
- printf("The next day is %.*s\n",ascii_time,ascii_time_len);
-
- }
-
-
- --
- Mark H. Granoff | Personal Computing Systems Network S/W Development Group
- ---------------------------------------------------------------------------
- Digital Equipment Corporation | Internet: granoff@keptin.enet.dec.com
- 30 Porter Road, LJO2/I4 | Usenet : ...!decwrl!keptin.enet!granoff
- Littleton, MA 01460 | AT&T : +1 508 486 2090
- ---------------------------------------------------------------------------
- Opinions herein are my own and do not necessarily reflect those of Digital.
-
-