;+
; PROJECT
;               SolarB EIS
;
; NAME
;               EIS_DELETE_TIMELINE_ENTRY
;
; CATEGORY
;               EIS planning
;
; PURPOSE
;               Function to mark a timeline entry as having been deleted.
;               Works in 2 ways.
;               Firstly the timeline "entry_type" tag is set as "D" - and
;               when I read the DB, I filter out these (those NOT marked
;               as deleted are added to the tlc) container.
;               Secondly I (as cunningly as a fox) reset the start and
;               stop times to some nonsense date - before launch. This is
;               brilliant and means when I read the database, I don't
;               have a lot of deleted studies to contend with!
;
; INPUTS
;
;
; WRITTEN
;               John A Rainnie, RAL Aug-2005
;
; VERSION
;               v0.1 JAR 17-Aug-2006
;                 Added changing start and stop times
;               v0.2 JAR 30-May-2007
;                 Bail out if seq_id = 0.
;
;-
;************************************************************************
FUNCTION eis_delete_timeline_entry , seq_id

IF (seq_id EQ 0) THEN RETURN , 1

DEFSYSV , '!PRIV', 2

; Open database for writing the new Study entry
db_name   = 'eis_timeline_db'
dbhname   = find_with_def(db_name+'.dbh', 'ZDBASE')
validFile = FILE_TEST( dbhname , /READ)
IF (validFile NE 1) THEN stop

dbopen, db_name, unavail = unavail , 1
IF (unavail NE 0) THEN stop

;
; Set start_time and stop_time to sometime before launch - 
; how's about my birthday (2000)! Ingenius!!!!
;
bday_date = anytim2tai('17-Oct-2000 00:00:00')
start_time = bday_date
end_time   = bday_date

;
; Update database entry with new values
dbput, 'ENTRY_TYPE'  , 'D'        , seq_id
dbput, 'START_TIME'  , start_time , seq_id
dbput, 'STOP_TIME'   , end_time   , seq_id

print,"Deleted seq_id = " + STRCOMPRESS(seq_id,/REMOVE_ALL)


RETURN , 1

END
