	FUNCTION AdjUsrTim, usrTim, sxtp=sxtp, sxtf=sxtf, bcs=bcs, $
			hxt=hxt, wbs=wbs
;	-----------------------------------------------------------
;+							21-June-91
;	Name:
;		AdjUsrTim 
;	Purpose:
;		Adjust and return new user input times, such that
;		the times corresponds to the earliest start time
;		of the data and the latest time of the data as a
;		result of key searches on the data.
;	CALLING SEQUENCE:
;		newt = AdjUstTim( usrTim, [sxtp=sxtp, sxtf=sxtf,
;				bcs=bcs, hxt=hxt, wbs=wbs])
;	INPUT:
;		usrTim	user input start and stop times.
;	Input/Keyword:
;		sxtp	sxtp data vector and times
;		sxtf	sxtf data vector and times
;		bcs	bcs data vector and times
;		hxt	hxt data vector and times
;		wbs	wbs data vector and times
;	Returned:
;		newt 	new start and stop times
;	History:
;		written 21-June-91 by GAL
;-
;	------------------------------------------------------------
;	ON_ERROR, 2	;force a return to caller if error occurs

;	Count the possible number of stop and start times:

	npairs = 0
	IF Keyword_SET(sxtp) THEN npairs = npairs + 1
	IF Keyword_SET(sxtf) THEN npairs = npairs + 1
	IF Keyword_SET(bcs) THEN npairs = npairs + 1
	IF Keyword_SET(hxt) THEN npairs = npairs + 1
	IF Keyword_SET(wbs) THEN npairs = npairs + 1


	newt = usrTim   			;default to user input	
	st = REPLICATE(usrTim(0), npairs)	;start times to compare
	et = REPLICATE(usrTim(1), npairs) 	;end times to compare

	i = 0			;dummy time index
	IF KEYWORD_SET(sxtp) THEN BEGIN
	  st(i).time = sxtp(0).time	;load 1st time from sxtp
	  st(i).day  = sxtp(0).day
	  nsxtp = N_ELEMENTS(sxtp)
	  et(i).time = sxtp(nsxtp-1).time	;load last time
	  et(i).day  = sxtp(nsxtp-1).day 
	  i = i + 1		;increment dummy time index
	ENDIF
	IF KEYWORD_SET(sxtf) THEN BEGIN
	  st(i).time = sxtf(0).time
	  st(i).day  = sxtf(0).day
	  nsxtf = N_ELEMENTS(sxtf)
	  et(i).time = sxtf(nsxtf-1).time
	  et(i).day  = sxtf(nsxtf-1).day
	  i = i + 1
	ENDIF
	IF KEYWORD_SET(bcs) THEN BEGIN
	  st(i).time = bcs(0).time
	  st(i).day  = bcs(0).day
	  nbcs = N_ELEMENTS(bcs)
	  et(i).time = bcs(nbcs-1).time
	  et(i).day  = bcs(nbcs-1).day
	  i = i + 1
	ENDIF
	IF KEYWORD_SET(hxt) THEN BEGIN
	  st(i).time = hxt(0).time
	  st(i).day  = hxt(0).day
	  nhxt = N_ELEMENTS(hxt)
	  et(i).time = hxt(nhxt-1).time
	  et(i).day  = hxt(nhxt-1).day
	  i = i + 1
	ENDIF
	IF KEYWORD_SET(wbs) THEN BEGIN
	  st(i).time = wbs(0).time
	  st(i).day  = wbs(0).day
	  nwbs = N_ELEMENTS(wbs)
	  et(i).time = wbs(nwbs-1).time
	  et(i).day  = wbs(nwbs-1).day
	ENDIF

;	Find first and last times:
	int2ex, st.time, st.day, stdate	;convert time format for calls
					;to Get1st and GetLast
	int2ex, et.time, et.day, etdate
print,'start',stdate
print,'stop',etdate
stop
	t1st = GET1st(stdate)		;earliest time
	ex2int, t1st, msod, ds79
	newt(0).time = msod(0)
	newt(0).day  = ds79(0)

;	Check for earliest data time before user input start time:
	IF (ds79(0) le usrTim(0).day) THEN BEGIN
	  IF (ds79(0) eq usrTim(0).day) THEN BEGIN
	    IF (msod(0) lt usrTim(0).time) THEN BEGIN
	      newt(0) = usrtim(0)	;yes--use user input instead
	    ENDIF
	  ENDIF ELSE BEGIN		;ds79<userTim.day
	    newt(0) = usrtim(0)
	  ENDELSE
	ENDIF

	tlast = GETLast(etdate)		;latest time
	ex2int, tlast, msod, ds79
	newt(1).time = msod(0)
	newt(1).day  = ds79(0)

	RETURN, newt
	END
