function str2time,s,informat=format,tformat=tformat
if keyword_set(tformat) then begin
ns = n_elements(s)
str = replicate(time_struct(0d),ns)
year = 0
p = strpos(tformat,'yy')
if p ge 0 then begin
year = fix(strmid(s,p,2))
year += 1900*(year ge 70) +2000 *(year lt 70)
endif
p = strpos(tformat,'YYYY')
if p ge 0 then year = fix(strmid(s,p,4))
str.year = year
p = strpos(tformat,'MM')
if p ge 0 then str.month = fix(strmid(s,p,2))
p = strpos(tformat,'DD')
if p ge 0 then str.date = fix(strmid(s,p,2))
p = strpos(tformat,'hh')
if p ge 0 then str.hour = fix(strmid(s,p,2))
p = strpos(tformat,'mm')
if p ge 0 then str.min = fix(strmid(s,p,2))
p = strpos(tformat,'ss')
if p ge 0 then str.sec = fix(strmid(s,p,2))
token='.'
repeat begin
token = token +'f'
p = strpos(tformat, token )
endrep until strpos(tformat,token+'f') lt 0
if p ge 0 then str.fsec = double(strmid(s,p,strlen(token)))
return,time_double(str)
endif
if not keyword_set(format) then format='YMDhms'
months= ['JAN','FEB','MAR','APR', 'MAY', 'JUN', 'JUL', 'AUG','SEP','OCT','NOV','DEC']
ss = strsplit(strupcase(s),' _-:/',/extract,count=nss)
for i=0,nss-1 do begin
w = where(ss[i] eq months,nw)
if nw gt 0 then ss[i] = strtrim(w[0]+1,2)
endfor
w = where(ss eq strlowcase(ss),nw)
ss = ss[w]
srt = sort(byte(format))
order = [2,1,0,3,4,5]
srto = srt[order]
ss = ss[srto[0:nw-1]]
str = strjoin(ss,' ')
return,time_double(str)
end