	FUNCTION GET1st, time
;	---------------------------------------------------------------
;+							21-June-91
;	NAME:
;		Get1st
;	Purpose: 
;		Find and return the first time from a list of times,
;		using the external format.
;	CALLING SEQUENCE:
;		firstTime = Get1st(time)
;       Input:
;		time 	list of times in external format
;	Returned:
;		first or earliest time in external format.
;	History:
;		written 25-Apr-90 by GAL
;		updated 21-June-91 for SOLAR-A
;-
;	---------------------------------------------------------------

	count = SIZE(time)
	nDataUnits = LONG(count(2))
	firstT = INTARR(7)

;	Mission Leap Years: 80, 84, 88 (366)
	
	doy = INTARR(1,nDataUnits)	;days since 1-Jan-80
	sod = INTARR(1,nDataUnits)	;seconds of the day since doy
	mons = [31,28,31,30,31,30,31,31,30,31,30,31]

	sod = LONG(time(0,*))*3600 + time(1,*)*60 + time(2,*)
	
	FOR i=0, nDataUnits-1 DO BEGIN
	  year = time(6,i)
	  mon  = time(5,i)
	  CASE 1 OF
	   (year eq 80): BEGIN			;leap yr
		doy(0,i) = FIX(TOTAL( mons(0:mon-1) ) ) + time(4,i)
	   END
	   (year eq 81): BEGIN
		doy(0,i) = FIX(TOTAL( mons(0:mon-1) ) ) + time(4,i) + 366
	   END
	   (year eq 82): BEGIN
		doy(0,i) = FIX(TOTAL( mons(0:mon-1) ) ) + time(4,i) + 731
	   END
	   (year eq 83): BEGIN
		doy(0,i) = FIX(TOTAL( mons(0:mon-1) ) ) + time(4,i) + 996
	   END
	   (year eq 84): BEGIN                  ;leap yr
		doy(0,i) = FIX(TOTAL( mons(0:mon-1) ) ) + time(4,i) + 1361
	   END
	   (year eq 85): BEGIN
		doy(0,i) = FIX(TOTAL( mons(0:mon-1) ) ) + time(4,i) + 1727
	   END
	   (year eq 86): BEGIN
		doy(0,i) = FIX(TOTAL( mons(0:mon-1) ) ) + time(4,i) + 2092
	   END
	   (year eq 87): BEGIN
		doy(0,i) = FIX(TOTAL( mons(0:mon-1) ) ) + time(4,i) + 2457
	   END
	   (year eq 88): BEGIN                  ;leap yr
		doy(0,i) = FIX(TOTAL( mons(0:mon-1) ) ) + time(4,i) + 2822
	   END
	   (year eq 89): BEGIN
		doy(0,i) = FIX(TOTAL( mons(0:mon-1) ) ) + time(4,i) + 3188
	   END
	   (year eq 90): BEGIN
		doy(0,i) = FIX(TOTAL( mons(0:mon-1) ) ) + time(4,i) + 3553
	   END
	   (year eq 91): BEGIN
		doy(0,i) = FIX(TOTAL( mons(0:mon-1) ) ) + time(4,i) + 3918
	   END
	   (year eq 92): BEGIN                  ;leap yr
		doy(0,i) = FIX(TOTAL( mons(0:mon-1) ) ) + time(4,i) + 4283
	   END
	   (year eq 93): BEGIN
		doy(0,i) = FIX(TOTAL( mons(0:mon-1) ) ) + time(4,i) + 4649
	   END
	   (year eq 94): BEGIN
		doy(0,i) = FIX(TOTAL( mons(0:mon-1) ) ) + time(4,i) + 5014
	   END
	   (year eq 95): BEGIN
		doy(0,i) = FIX(TOTAL( mons(0:mon-1) ) ) + time(4,i) + 5379
	   END
	   (year eq 96): BEGIN			;leap yr
		doy(0,i) = FIX(TOTAL( mons(0:mon-1) ) ) + time(4,i) + 5744
	   END
	   (year eq 97): BEGIN
		doy(0,i) = FIX(TOTAL( mons(0:mon-1) ) ) + time(4,i) + 6110
	   END
	  ELSE:	Print,'Not a valid Year'
	  ENDCASE
	ENDFOR                                                         
	mind = MIN(doy)
	idxmin = WHERE(mind eq doy)
	lend = SIZE(idxmin)
	IF (lend(1) EQ 1) THEN BEGIN	;There is only one
	  theOne = idxmin(0)
	ENDIF ELSE BEGIN		;More than one MIN, ck SOD
	  mins = MIN(sod(idxmin))
	  idxmins = WHERE(mins EQ sod)
	  lens = SIZE(idxmins)
	  IF (lens(1) EQ 1) THEN BEGIN	;there is only one
	    theOne = idxmins(0)
	  ENDIF ELSE BEGIN
	    theOne = idxmins(0)		;tie!!! pick one
	  ENDELSE
	ENDELSE


	firstT(0) = time(*,theOne) 

	RETURN, firstT
	END
