;+
;Function YYDOY_2_UT, TIME
;
;Purpose: Converts time from Year (YY)  and Day of Year (DOY)
;		into the UTIME format, sec from 79/1/1.
;
;Inputs:  Time - [YY,DOY] a 2 element or 2 x n vector 
;		 or a string or string array in the format 'YYDOY'
;		 where YY is the last 2 digits of the year from 1950-2049, 
;		 i.e. 80 for 1980 and 
;		 DOY starts from 1
;Output:  Returns time in double precision seconds from 
;	  79/01/01, the standard UT format.  
;	  
;Restrictions:
;		 Limited to 1950-2049, 'YYDOY' must have 5 characters.
;RAS, 93/1/25
;	
;*******************************************************************************
;-
function yydoy_2_ut, yydoy; convert year and day to utime,vec or string

yrday = yydoy
dim = (size( yydoy))(0) ;dimension of input array

;GET STRING YEAR AND CONVERT DAY TO OFFSET UTIME

type = datatype( yrday )
if type eq 'STR' then begin

;HELPBLOCK
  if STRUPCASE(yrday(0)) eq 'HELP' then begin
	print,'yydoy_2_ut(yydoy) ; convert year and day to utime,[yy,doy] or ''yydoy'''
	ans=0
	goto,return1	
  endif
;HELPBLOCK

  sdoy = strmid(yrday,2,3)
  syy  = strmid(yrday,0,2)
  doy=fix(sdoy) ;convert string to integer
  goto,ans1

endif else begin ; 2xn array of years and days of year

; vector of yr and doy: [yr,doy]
  yrday = reform( yrday, 2, n_elements(yrday)/2)
  syy=strtrim(fix(yrday(0,*)),2)
  doy=yrday(1,*)

ENDELSE

;convert to utime
ANS1:
ans = ( utime( syy+'/01/01' ) + (doy-1)*86400.d0 )(*)

;if a scalar or 1d vector passed, then return a scalar

if ((type ne 'STR') and (dim eq 1)) or $
	((type eq 'STR') and (dim eq 0)) then ans = ans(0)

RETURN1:

return, ans
end
