function t = iOS2time(stuff)
% function t = iOS2time(stuff)
% This function takes the structure created by the importdata function when
% importing a data file from the iOS version of Physics Toolbox and returns
% a vector of the elapsed time in seconds. It is left for the user to
% extract the other imported data in the structure. This function just deals 
% with the time stamp array.
% 
% input:    stuff = structure created by the importdata function when
%                   importing a data file from the iOS version of Physics Toolbox
% output:   t = vector of elapsed times [seconds]
%
% For Example: if you have a file "iOSPhysicsTool.csv" and you run:
%       >> Accel = importdata('iOSPhysicsTool.csv');
%       >> t = iOS2time(Accel);
%           The variable t would contain the elapsed time in seconds 
%           (to the nearest millisecond). 

% Other variables: tc, ts, td, = time in various formats 
%                  dt  = change in time for each interval in time format 

% Create a vector of time stamps, eliminate first value (as it is the title
% "time" and is not data)
tc = stuff.textdata(2:end,1);

% convert time data from a cell array of strings to a string array
ts = string(tc);

% converting string array to datetime format 
td = datetime(ts, 'InputFormat', 'yyyy-MM-dd HH:mm:ss.SSS');

% calculate elapsed time
dt = td - td(1);

% express elapst time in seconds
t = seconds(dt);
