function pick_times,tstart,tend,last=last,$
         dtimes=dtimes,ctimes=ctimes


if not exist(ctimes) then ctimes=[0.d,0.d]

;-- start with defaults

times_in=exist(tstart) or exist(tend)
times=[0.d,0.d]
if exist(dtimes) then begin
 if (dtimes(0) gt 0.) then times(0)=anytim2tai(dtimes(0))
 if (dtimes(1) gt 0.) then times(1)=anytim2tai(dtimes(1))
endif

;-- substitute user inputs

if exist(tstart) then times(0)=anytim2tai(tstart)
if exist(tend) then times(1)=anytim2tai(tend)

;-- substitute common block variables if user requests last times 
;   or no times are input

if keyword_set(last) or (not times_in) then begin
 if exist(ctimes) then begin
  if (ctimes(0) gt 0.) then times(0)=anytim2tai(ctimes(0))
  if (ctimes(1) gt 0.) then times(1)=anytim2tai(ctimes(1))
 endif
endif

;-- if still no times, substitute defaults

if exist(dtimes) then begin
 if (times(0) eq 0.d) and (dtimes(0) gt 0.) then times(0)=anytim2tai(dtimes(0))
 if (times(1) eq 0.d) and (dtimes(1) gt 0.) then times(1)=anytim2tai(dtimes(1))
endif

return,times & end