pro getcputime,pckt,firstday,time,cdstime=cdstime
;+
;     pckt = array of packets from TLM stream generated by DACS organized
;            with time as the second dimension
;     firstday is the kday number of the first day in time
;     time is a floating array of the number of hours since firstday
;
;     cpu time is year, doy, hour, min, sec 
;         word:    1,    2 ,   3 ,  4 ,  5
;
;    modified for pckt in either bytes or words, 3 Mar 1996 RAH
;    22 Mar 1996  RAH, if byte packets, then assume read in with /no_hdr option
;    
; @(#)getcputime.pro	1.1 01/23/98 :LASCO IDL LIBRARY
;
;-
sz=size(pckt)
if (sz(sz(0)+1) eq 1) then begin
   offset=12
   lobt_tai = obt2tai(pckt(offset-6:offset-1,*))
   cdstime=tai2utc(lobt_tai)
   firstday = cdstime(0).mjd
   time = (cdstime.mjd-firstday)+cdstime.time/3.6e6		; convert from msec to hours
endif else begin
   kd = lonarr(n_elements(pckt(1,*)))
   for i=0,n_elements(kd)-1 do begin kday,1,1,pckt(1,i),t & kd(i)=t & endfor
   kd = kd+pckt(2,*)   ; this should have 1 subtracted
   time=float(kd)+((pckt(5,*)/60.+pckt(4,*))/60.+pckt(3,*))/24.
   firstday = long(time(0))
   time = 24.*(time-firstday)
endelse
return
end

