function outtimes = getTimeStr(h)
%GETABSTIME Extract an absolutly defined time vector as a string cell array
%
% GETABSTIME(TS) extracts the time vector as a cell array of datestrs if
% the time vector is defined absolutely, i.e., a valid start time is
% defined. If in addiiton the format is defined as a valid date format
% string the output datestrs will conform to the specified format.
%
%   Author(s): James G. Owen
%   Copyright 1986-2003 The MathWorks, Inc. 
%   $Revision: 1.1.6.1 $  $Date: 2004/12/26 21:35:04 $

%% Parse the format 
[outflag,absflag] = tsIsDateFormat(h.timeInfo.Format);
% if ~outflag
%     error('timeseries:getTimeStr:invformat','time series object is not in absolute date/time format.')
% end

% Get numeric time vector in days
if ~isempty(h.timeInfo.Startdate)
     t = datenum(h.timeInfo.Startdate) + ...
         h.Time * tsunitconv('days',h.timeInfo.Units);
     if outflag
         outtimes = cellstr(datestr(t,h.timeInfo.Format));
     else
         outtimes = cellstr(datestr(t));
     end
elseif isempty(h.timeInfo.Startdate) && outflag && ~absflag
    t = h.Time * tsunitconv('days',h.timeInfo.Units); 
    outtimes = cellstr(datestr(t,h.timeInfo.Format));
elseif isempty(h.timeInfo.Startdate) && ~outflag 
    t = h.Time;
    outtimes = cell([length(t) 1]);
    for k=1:length(t)
        outtimes{k} = sprintf('%f',t(k));
    end
else
    error('timeseries:getTimeStr:invformat',...
        'Absolute formats require a valid StartTime proeprty')
end
