		Clunk et al.

	CLUNK.MAC contains routines for converting from ascii DEC style date
and time to clunk style (64bit integer) date/time, and visa versa.

	A "clunk" is 100 nanoseconds (10 million clunks = 1 second). A clunk
date is defined as the number of clunks (herein expressed as a 64 bit integer)
since November 17,1858 - the date that the first photographic plate was 
exposed at the Smithsonian Astrophysical Laboratory ushering in the age of 
modern astronomy.

	DEC uses clunk dates for recording time in VMS. Likewise VMS 
Datatrieve and RSX Datatrieve store and work with clunk dates. The conversion 
routines in CLUNK.MAC allow us to convert from ASCII date and time, to the 
nearest second, into clunk date and visa versa.

	Uses include converting Datatrieve stored dates into ASCII dates,
converting ASCII dates into clunk dates so that Datatrieve can read them,
and creating a continuous numeric date/time for time stamping events 
and easily calculating time intervals.

	This routine for converting between ASCII date and time (between 
1900 and 1999) and clunks was obtained from an '82 Multitasker article by Bob 
Rock of Northern Telecom Inc. (APR-81) and modified by Phil Hannay here at
Cargill to detect illegal year input and correct the second and minute 
conversion of the time input.

	On testing it was discovered that as originally submitted the routine 
exhibited discontinuities in the clunk times. Investigation revealed two 
sources of error.

	 The first was an error in the definitions that were used for 1 second,
1 minute and 1 hour in clunks, and the second was a problem in the routine
for adding two 64 bit numbers.

	Included in this submission are the macro routine as modified to
solve both of the forementioned problems, a Fortran program for testing it,
and command files to compile both and build the program.

	The Fortran program also provides a method of converting the four-
integer clunk date into a single double-precision value, which is adequate 
when working to the nearest second.

	When you run "TSTTIM", it will ask for the date and time to be 
converted in standard RSX-11 notation (e.g. 27-AUG-86 17:58:52) and report back:
1. the date and time as entered, 2. the clunk time expressed as four words and 
as a decimal number divided by 10,000,000 (i.e. seconds ), 3. the difference 
between the current time and the previously entered time in seconds (back 
calculated from the clunk time) and finally, 4. the clunk routine return 
status. 

	The program will exit on a negative return status (e.g. a null date 
and time entry).

Example:

Date      Time       Word1      2      3     4 Clunk Time(secs)  Diff    Stat

22-AUG-86 00:00:00       0   7230  15547   143  4031769600.000 4031769600.  1
22-AUG-86 00:00:01  -27008   7382  15547   143  4031769601.000          1.  1
22-AUG-86 00:01:01   -9088  16537  15547   143  4031769661.000         60.  1

	Points at which the previous submission was discontinuous were at the 
transition from hours to days (i.e. 22-AUG-86 23:59:59 to 23-AUG-86 00:00:00)
and at unique times when a special cascading carry bit condition occurred in 
the 64 bit addition (e.g. 05-JUN-86 17:09:27). 


Directory:

README.CLU - this file
CLUNK.MAC - conversion subroutines
TSTTIM.FTN - F77 source for testing conversion routines
TSTTIM.CMD - command file to build TSTTIM
TSTTIM.TKB - task build command file for TKB to build TSTTIM


If you have any questions or find any bugs, contact...

SEP-86
Bob Thomas 
AMI/Research Bldg.
Cargill inc.
P.O. Box 9300
Mpls, MN 55440
(612) 475-5432

