;+
; NAME:
; euv_date2arr.pro
;
;
;
; PURPOSE:
; parse an euv date of format yyyydddhhmmss into an array
; of the form [yyyy,ddd,hh,mm,ss]
;
;
;
; CATEGORY:
; time conversion
;
;
;
; INPUTS:
; euv_date: an euv time sting or long integer in one of the forms
; yyyydddhh
; yyyydddhhmm
; yyyydddhhmmss
;
;
; KEYWORD PARAMETERS:
; STRING: outputs the resulting array in type string
;
;
;
; OUTPUTS:
; output array in type int (or string w/ keyword)
; NaN if invalid input
;
;
; EXAMPLE: time_arr = euv_date2arr(2002123124534)
;
;
;
; MODIFICATION HISTORY:
;
; Mon Mar 31 15:06:16 2008, Brian Larsen
; added check and removal of leading 'e' from downloaded fits
;
; Thu Feb 8 14:54:02 2007, Brian Larsen
; total rewrite for speed, no more '-' functionality
;
; Wed Jan 17 09:16:32 2007, Brian Larsen
; Cleaned up with case statment and added message
; ioerror instead or returing NaN
;
; Thu Aug 10 10:02:52 2006, Brian Larsen
; added '-' functionality for sim difference data
;
; Thu Mar 2 14:37:03 2006, Brian Larsen
; added array ability with recursion
;
;
; Thu Oct 6 22:17:26 2005, Brian Larsen
; added ability to get rid of path info on the front of filenames
;
;
; 14-Feb-2003 created Brian Larsen
;
;
;-
FUNCTION euv_date2arr, euv_date, STRING=string
compile_opt strictarr
IF N_ELEMENTS(euv_date) EQ 0 THEN $
message, 'invalid EUV date', /ioerror
;; turn into a string if it isnt
IF size(euv_date, /type) NE 7 THEN $
euv_date = trim(euv_date)
; get rid of any path information first
;; strsplit is not vectorized :(
spl = strarr(N_ELEMENTS(euv_date))
FOR i=0l, N_ELEMENTS(spl)-1 DO BEGIN
IF strmid(euv_date[i], 0, 1) EQ 'e' THEN euv_date[i] = (strsplit(euv_date[i], 'e', /extract))[0]
tmp = strsplit(euv_date[i], '/', /extract)
spl[i] = tmp[N_ELEMENTS(tmp)-1]
tmp = strsplit(spl[i], '.', /extract)
euv_date[i] = tmp[0]
ENDFOR
euv_date = strtrim(euv_date) ; no pesky leading or trailing spaces
mask = '001000000'
euv_date = euv_date + strmid(mask, strlen(euv_date)-4)
time_arr = strarr(5, N_ELEMENTS(euv_date))
reads, euv_date, time_arr, format='(a4,a3,a2,a2,a2)'
IF NOT KEYWORD_SET(string) THEN time_arr = long(time_arr)
RETURN, time_arr
END