.TITLE CLUNK
.IDENT /V1.0/
.SBTTL CONSTANTS AND BUFFERS
;
;			--- AUTHORED BY ---
;
;			BOB ROCK
;			NORTHEAST ELECTRONICS DIV.
;			NORTHERN TELECOM INC.
;			AIRPORT RD.
;			CONCORD, N.H. 03301
;			(603) 224-6511 EXT 347
;
;	FORTRAN CALLABLE ROUTINE TO COVERT TO AND FROM
;	DATATRIEVE CLUNKS AND RSX-11 FORMAT TIME AND DATE
;
;		BY BOB ROCK	APR-81
;
;	LAST EDIT: 25-OCT-1987 16:36:53 
;
;	BASIC PLUS-2
;		CALL C2DATE BY REF (CLUNKS%(),C.DATE$,C.TIME$,STATUS%)
;
;			CLUNKS% IS A 4 WORD INTEGER ARRAY
;			C.DATE$ MUST BE A 9 CHAR MIN. STRING
;			C.TIME$ MUST BE A 8 CHAR MIN. STRING
;			STATUS% RETURNS FOLLOWING RESULTS:
;				1 = SUCCESS
;				-1 = ERROR - DATE WAS PRIOR TO 1900
;				-2 = ERROR - DATE AFTER 1999
;                               -3 = ERROR - CLUNK OVERFLOW
;
;
;  THIS ROUTINE HAS BEEN MODIFIED BY PHILIP HANNAY, CARGILL GRAIN LAB,
;    3444 DIGHT AV S, MINNEAPOLIS, MN. 55407,  (612)-721-8531, FOR
;    OUR USE.  THE MODIFICATIONS ARE ACTUALLY CORRECTIONS, ONE
;    TO DETECT ILLEGAL CHARACTERS IN THE ASCII YEAR INPUT, THE OTHER
;    TO DO CORRECT DECIMAL TO BINARY CONVERSION OF THE MINUTES AND
;    SECONDS OF THE ASCII TIME INPUT.  JULY 6, 1982.  THIS ROUTINE
;    USES THE STANDARD DEC CALL SITE SO IT CAN BE CALLED BY FORTRAN OR
;    BY OMSI PASCAL V2.0 WITH NO CHANGES.
;
;  IT WAS FURTHER MODIFIED BY BOB THOMAS,CARGILL,INC.,P.O. BOX 9300
;    MPLS,MN,55440, (612)475-5432. THOSE FURTHER MODIFICATIONS
;    WERE TO CORRECT THE VALUES FOR 1 SEC, 1 MIN AND 1 HOUR. IN
;    ADDITION THE ADD64 ROUTINE WAS REWRITTEN TO PROVIDE FOR CASCADING 
;    CARRY BITS (SUCH AS THOSE THAT OCCUR ON 05-JUN-86 17:09:27).
;
;
;  PETER STADICK  24-MAY-87 - MODIFIED BY ADDING PROGRAM SEGMENTS. 
;    YOU CAN BUILD THIS INTO I/D SPACE TASKS.
;
.PSECT CLUDAT,RW,D,LCL,REL
; SOME USEFUL CONSTANTS...
;
;	NOTE:
;		FORMAT OF LONG WORDS IS LSW,...,MSW
;  A SECOND - 10,000,000 CLUNKS
;
SEC:  .WORD 113200,000230,000000,000000
;
;  A MINUTE - 600,000,000 CLUNKS
;
MIN:  .WORD 043000,021703,000000,000000
;
;  AN HOUR - 36,000,000,000 CLUNKS
;
HOUR:  .WORD 064000,060704,000010,000000
;
;  A DAY - 864,000,000,000 CLUNKS
;
DAY:	.WORD 140000,025151,000311,000000
;
;  A WEEK - 6,048,000,000,000 CLUNKS
;
WEEK:	.WORD 040000,024344,002600,000000
;
;  28 DAYS - 24,192,000,000,000 CLUNKS
;
DAY28:	.WORD 000000,121621,013000,000000
;
;  29 DAYS - 25,056,000,000,000 CLUNKS
;
DAY29:	.WORD 140000,146772,013311,000000
;
;  30 DAYS - 25,920,000,000,000 CLUNKS
;
DAY30:	.WORD 100000,174144,013622,000000
;
;  31 DAYS - 26,787,000,000,000 CLUNKS
;
DAY31:	.WORD 040000,021316,014134,000000
;
;  NON-LEAP YEAR (365 DAYS) - 306,600,000,000,000 CLUNKS
;
DAY365: .WORD 140000,074306,017321,000001
;
;  LEAP YEAR (366 DAYS) - 307,440,000,000,000 CLUNKS
;
DAY366: .WORD 100000,121460,017632,000001
;
;  OFFSETT FROM 17-NOV-1858 TO 1-JAN-1900
;
OFFSET:	.WORD 000000,072215,015304,000056
;
;  THE ASCII MONTH TABLE
;
ASCMON:	.ASCII /JAN/
	.ASCII /FEB/
	.ASCII /MAR/
	.ASCII /APR/
	.ASCII /MAY/
	.ASCII /JUN/
	.ASCII /JUL/
	.ASCII /AUG/
	.ASCII /SEP/
	.ASCII /OCT/
	.ASCII /NOV/
	.ASCII /DEC/
;
;  DAYS PER MONTH TABLE
;
DAYMON:	.BYTE 31.,28.,31.,30.,31.,30.,31.,31.,30.,31.,30.,31.
;
;  CLUNKS PER MONTH TABLE
;
CLDAY:	.WORD DAY31	; JAN
	.WORD 0		; FEB SET BY APPROPRIATE ROUTINE FOR LEAP YEAR OR NOT
	.WORD DAY31	; MAR
	.WORD DAY30	; APR
	.WORD DAY31	; MAY
	.WORD DAY30	; JUN
	.WORD DAY31	; JUL
	.WORD DAY31	; AUG
	.WORD DAY30	; SEP
	.WORD DAY31	; OCT
	.WORD DAY30	; NOV
	.WORD DAY31	; DEC
;
;  SOME USEFUL INTERMEDIATE STORRAGE LOCATIONS
;
TEMP1:	.WORD 0,0,0,0

TEMP2:	.WORD 0,0,0,0

TEMP3:	.WORD 0,0,0,0

CLUNKS:	.BLKW 4

DATE:	.BLKB 9.	; FORMAT DA-MON-YR
	.BYTE 0
TIME:	.BLKB 8.	; FORMAT HH:MM:SS
	.BYTE 0

	.EVEN
BYEAR:	.WORD 0
BMONTH:	.WORD 0
BDAY:	.WORD 0
BHOUR:	.WORD 0
BMIN:	.WORD 0
BSEC:	.WORD 0

STATUS:	.WORD 0

.SBTTL CONVERT CLUNKS TO SYSTEM DATE AND TIME

