function outtimes = getAbsTime(h)
%GETABSTIME  Extract an absolutly defined time vector as a string cell array
%
%   getAbsTime(TS) extracts the time vector from the time series object TS 
%   as a cell array of date strings (see DATESTR for help on date strings). 
%   The time vector must be defined absolutely, i.e. the property 
%   TimeInfo.StateDate must be defined. When the TimeInfo.StartDate format 
%   is a valid DATESTR format, the output format from getAbsTime conforms 
%   to the same.
%
%   Note that this method is case sensitive.
%
%   Example:
% 
%   Create a time series object:
%   ts=tsdata.timeseries(rand(5))
%
%   Set the StartDate property:
%   ts.TimeInfo.StartDate='10/27/1974 07:05:36'
%
%   Extract a vector of absolute time values:
%   getAbsTime(ts)
%
%   See also TSDATA.TIMESERIES/SETABSTIME, TSDATA.TIMESERIES/TIMESERIES

%   Author(s): Rong Chen
%   Copyright 1986-2003 The MathWorks, Inc. 
%   $Revision: 1.1.6.1 $  $Date: 2004/12/26 21:35:02 $

% Only work if the timu vector is absolute
if isempty(h.timeInfo.Startdate)
    error('The time vector is relative')
end

% Get numeric time vector in days
t = datenum(h.timeInfo.Startdate) + h.Time * tsunitconv('days',h.timeInfo.Units);

% If a valid datestr format is specified then use it
if tsIsDateFormat(h.timeInfo.Format)
    outtimes = cellstr(datestr(t,h.timeInfo.Format));
else
    outtimes = cellstr(datestr(t,'dd-mmm-yyyy HH:MM:SS'));
end
