;+
;
; NAME: 
;	BATSE_FILE2TIME
;
; PURPOSE:
;	This function constructs a time from the SDAC standard format file names.
; 	i.e. yymmdd_hhmm.whatever for fdb, cont, discsp,  yymmdd.bdb for bdb files.
;
; CATEGORY:
;	BATSE
;
; CALLING SEQUENCE:
;
;
; CALLS:
;       none
;
; INPUTS:
;       BATSE archive database filename, e.g. 960513_2329.FDB_4574
;
; OPTIONAL INPUTS:
;       none
;
; OUTPUTS:
;       none explicit, only through commons;
;
; OPTIONAL OUTPUTS:
;       none
;
; KEYWORDS:
;       none
; COMMON BLOCKS:
;       none
;
; SIDE EFFECTS:
;       none
;
; RESTRICTIONS:
;       none
;
; PROCEDURE:
;       none
;
; MODIFICATION HISTORY:
;
; K Tolbert 13 Apr 1994
; A Skowronek 3 June 1996 Made time a dblarr - utime puts out double
;	Version 3, RAS, changed from file2time re SSW conflict
; RCJ 29 Sep. 1997 - 'underscore' -> 'underscore+1' to read time correctly.
;-

function batse_file2time, filename

break_file, filename, disk, dir, filnam, ext

n = n_elements(filename)
time = dblarr(n)                                                                   

for i = 0,n-1 do begin
   year = strmid(filnam, 0, 2)
   month = strmid(filnam, 2, 2)
   day = strmid(filnam, 4, 2)
   underscore = strpos(filnam, '_') 
   timeofday = '0'
   if underscore ne -1 then begin
      timeofday = strmid(filnam, underscore+1, 4)
      if strlen(timeofday) ne 4 then timeofday = '0'
   endif   
   time(i) = utime(year+'/'+month+'/'+day+','+timeofday)
   next:
endfor

if n_elements(time) eq 1 then time = time(0)

return, time & end
