home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.vms
- Path: sparky!uunet!spool.mu.edu!uwm.edu!linac!unixhub!slacvx.slac.stanford.edu!fairfield
- From: fairfield@slacvx.slac.stanford.edu
- Subject: Re: Anybody have time arithmetic routines?
- Message-ID: <1993Jan21.002747.1@slacvx.slac.stanford.edu>
- Lines: 58
- Sender: news@unixhub.SLAC.Stanford.EDU
- Organization: Stanford Linear Accelerator Center
- References: <1993Jan21.020035.18787@slcs.slb.com>
- Date: Thu, 21 Jan 1993 08:27:47 GMT
-
- In article <1993Jan21.020035.18787@slcs.slb.com>, brydon@asl.slb.com (Harvey Brydon (918)250-4312) writes:
- > I have to do some reporting on some timing tests and have a need to calculate
- > elapsed times for a number of values. Is there a way to calculate this in a
- > simple fashion (DCL preferred, Fortran otherwise)? I'll be parsing the
- > timestamps from an RMS file with DCL. Before I get a league of answers about
- > calculating delta time from 'now', let me make it clear I need to calculate
- > this from two arbitrary timestamps. eg:
- >
- > $ t1 = "20-JAN-1993 08:07:09.03"
- > $ t2 = "20-JAN-1993 10:22:13.44"
- > $! (magic dcl here)
- > $ show sym diff ==> "0 02:15:04.41"
-
- [etc...]
-
- There was a thread on a related topic going on just a week ago
- under the subject ` Implimenting "TOMMORROW + 1:00:00" ' (that's
- pretty close anyway). Check there, but also see below...
-
- > Anybody have any tricks for this or is it just a matter of brute force
- > parsing, adding and carrying?
-
- I'm sure it _can_ be done in DCL, but I'd suggest Fortran instead:
- no need to parse, add or carry ;-) Here's an outline:
-
- 1) Use LIB$GET_SYMBOL to read in your two (or more) DCL time
- symbols, t1 and t2.
-
- 2) Use SYS$BINTIM to convert each to 64-bit internal time (quadword,
- just use a 2-long integer*4 array).
-
- 3) Use LIB$SUB_TIMES to get the 64-bit delta time between the t1
- and t2 quadwords (there's also a LIB$ADD_TIMES for doing your
- delta time additions).
-
- 4) Use SYS$ASCTIM to convert the time quadword result back
- to an ascii time string. I think there are flags to
- control whether you get an "absolute" or a "delta" time
- back...check the help/docs, it could be automatic.
-
- 5) Use LIB$SET_SYMBOL to define a DCL symbol containing the
- resultant delta ascii time string.
-
- There are no item lists involved so about half a page of Fortran
- ought to do it (OK, OK! A page and a half with proper return status
- checking and comments :-).
-
- You'll suffer image activation time overhead compared to doing
- it all in DCL, but I'll bet it's faster just the same! Certainly
- simpler to code, more flexible, and less error-prone.
-
- -Ken
- --
- Dr. Kenneth H. Fairfield | Internet: Fairfield@Slac.Stanford.Edu
- SLAC, P.O.Box 4349, MS 98 | DECnet: 45537::FAIRFIELD (45537=SLACVX)
- Stanford, CA 94309 | BITNET Fairfield@Slacvx
- ----------------------------------------------------------------------------
- These opinions are mine, not SLAC's, Stanford's, nor the DOE's...
-