function test_time(varargin)
% A test function to submit a time to the repository. The time is then
% retrieved and compared to the original one.
% 
% Usage: test_time()     - connects to Hannover repository
%        test_time(conn) - connects to the repository specified by
%                                  the database conn object.
% 
% M Hewitson 24-02-08
% 
% $Id: test_time.m,v 1.4 2008/02/24 10:17:54 hewitson Exp $
% 

if nargin == 0
  conn = mysql_connect('130.75.117.67', 'ltpda_test');
else
  conn = varargin{1};
end

%% Submit a timeformat
p = time();              

sinfo.conn                   = conn;
sinfo.experiment_title       = 'submit time';
sinfo.experiment_description = 'this is just a test of the whole thing';
sinfo.analysis_description   = 'just submitting';
sinfo.quantity               = 'none';
sinfo.keywords               = 'none';
sinfo.reference_ids          = '1,2';
sinfo.additional_comments    = 'none';
sinfo.additional_authors     = 'no one';

[ids, cid] = ltpda_obj_submit(p, sinfo);

%% Retrieve the object

q = ltpda_obj_retrieve(conn, ids);

%% Close connection
if nargin == 0
  close(conn);
end


%% Test

if p ~= q
  error('### time objects are not the same.')
end
