C   ---------------------------------------------------------------------------
C   TIMECUR.FOR - The function of this routine is to determine the current
C	system time and the processes current connect time.  The values are
C	converted to string data and returned as the function value of the
C	routine.
C
C   Calling Procedure:
C
C	return_string = TIMECUR ( login_time )
C
C   Entry Conditions:
C
C	login_time - This must be the time to subtract from the current system
C		time in order to get the delta time.  If zero is passed than
C		the process login time is used instead.
C
C   Exit Conditions:
C
C	A character string with the current time and the current connect time
C	will be returned as the value of the function.
C
C	The format of returned string is:
C
C		TIMECUR = 'dd-mmm-yyyy:hh:mm:ss.hh<tab>dddd-hh:mm:ss.hh'
C
C	Leading blanks will be included.
C
C   ---------------------------------------------------------------------------
C
	CHARACTER*40 FUNCTION TIMECUR ( LOGINTIM )
C
	IMPLICIT INTEGER*4 (A-Z)
C
	PARAMETER	ABSZ=23
	PARAMETER	DELTAZ=16
	PARAMETER	DASH='-'
	PARAMETER	EQUAL=':='
	PARAMETER	COLON=':'
	PARAMETER	TAB='	'
C
	CHARACTER	ABS_C*(ABSZ)
	CHARACTER	JPI_LOGINTIM*(ABSZ)
	CHARACTER	DELTA_C*(DELTAZ)
C
	INTEGER*4	ABS(2), ABS_S
	INTEGER*4	LOGINTIM(2), LOGINTIM_S
	INTEGER*4	DELTA(2), DELTA_S
C
C   ---------------------------------------------------------------------------
C
C   Fetch the processes login time.
C
	IF ( LOGINTIM(1) .EQ. 0 ) THEN
		TIMECUR = JPI_LOGINTIM ( LOGINTIM, LOGINTIM_S )
	ENDIF
C
C   Fetch the current character system time.
C
	CALL SYS$ASCTIM ( ABS_S, ABS_C, , %VAL(0) )
C
C   Convert the current system time to binary system time
C
	CALL SYS$BINTIM ( ABS_C, ABS )
C
C   Subtract the login time from the current system time to get connect time.
C	Note: that the acutal calculation is done to yeald negative result
C	      because delta times are negative values.
C
	CALL LIB$SUBX ( LOGINTIM, ABS, DELTA, 2 )
C
C   Convert the binary connect time to character.
C
	CALL SYS$ASCTIM ( DELTA_S, DELTA_C, DELTA, %VAL(0) )
C
C   Insert the colon between year & hour, and insert the dash between 
C	day & hour.
C
	ABS_C(12:12) = COLON
	DELTA_C(5:5) = DASH
C
C   Format the retrun string.
C
	TIMECUR = ABS_C // TAB // DELTA_C
C
C   Return.
C
	RETURN
	END
