function anytim2tai, dt, errmsg=errmsg, nocorrect=nocorrect, quiet=quiet
 
;
;  set default return value
;
tai = 0.0D0

on_error, 2   ;  Return to the caller of this procedure if error occurs.
message=''    ;  Error message returned via ERRMSG if error is encountered.
;
;  see if any parameters were passed
;
if n_params() eq 0 then begin
    message = 'Syntax:  TAI = ANYTIM2TAI(DATE-TIME)'
    goto, handle_error
endif

;
;  determine type of input 
;
type = datatype(dt,1)

;
; see if the input is an array
;
np = n_elements(dt)
if np gt 1 then tai = replicate(tai, np)

;
; act accordingly
;
case type of
      'Double':  tai = dt
          else:  begin
        message=''
                utc = anytim2utc(dt,errmsg=message)
                if message eq '' then tai = utc2tai(utc,nocorrect=nocorrect)
        end
endcase

if message eq '' then goto, finish
;
; Error handling point.
;
handle_error:
    if n_elements(errmsg) eq 0 then message, message, /continue
    errmsg = message
;
finish:
    return, tai
    end