;+
; PROJECT:
;	HESSI
; NAME:
;	hsi_sctime_type
;
; PURPOSE:
;	This function returns the type code of a HESSI time format. .
;
; CATEGORY:
;	HESSI, UTIL, TIME
;
; CALLING SEQUENCE:
;
;
; CALLS:
;	none
;
; INPUTS:
;	sctime - time in one of these three formats:
;	Valid HESSI time formats
;       Time in spacecraft full format structure {hessi_sctime_full} (binary (busec) accuracy), or
;		time in spacecraft short format {hessi_sctime} (truncated to 16 busec accuracy) or
;		New (18 sep 2001) Long64 format.  Full busec accuracy using 64 bits.
;
; OPTIONAL INPUTS:
;	none
;
; OUTPUTS:
;       If valid returns one of these three strings:'HESSI_SCTIME_FULL', 'HESSI_SCTIME', 'LONG64'
;		If not valid, returns the null string ''.
;
; OPTIONAL OUTPUTS:
;	none
;
; KEYWORDS:
;		ALL_TYPE - access the three valid type strings.
;
; COMMON BLOCKS:
;	none
;
; SIDE EFFECTS:
;	none
;
; RESTRICTIONS:
;	none
;
; PROCEDURE:
;	none
;
; MODIFICATION HISTORY:
;
;	18-sep-2001
;		richard.schwartz@gsfc.nasa.gov
;
;-

function hsi_sctime_type, sctime, all_type=all_type

all_type = ['HESSI_SCTIME_FULL', 'HESSI_SCTIME', 'LONG64']
;
; Is it a structure?
it_is_struct = size(/tname, sctime) eq 'STRUCT'
match_count = 0

if it_is_struct then begin
	str_name = tag_names(/struct, sctime)
	match = where( str_name eq ALL_TYPE, match_count)
	if match_count eq 0 then begin
		tags = tag_names( sctime )
		test = ['SECONDS', 'BMICRO','BMICRO16']
		wtest = where_arr( test, tags, wmatch)
		if wmatch eq 2 then $
			return, (max(wtest) eq 1 ) ? 'HESSI_SCTIME_FULL':'HESSI_SCTIME'

    endif
    endif else begin
	Input_type = size(/tname, sctime)
	match = where( Input_type eq ALL_TYPE, match_count)

	endelse


return, match_count ? all_type[match[0]] : ''

end