FROMTIMESTRING creates a time object from a time string. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FUNCTION: fromTimeString DESCRIPTION: Construct a time object from a string value CALL: tt = fromTimeString(tt, plist) INPUT: tt: input time object plist: plist object which must contain the key 'time_str' EXAMPLES: Some examples for the value of the key 'time_str' '2008-06-29 14:00:00.000' '14:00:00.000 2008-06-29' '14:00:00 29-06-2008' '14:00:00' HISTORY: 07-05-2007 Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % FROMTIMESTRING creates a time object from a time string. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % FUNCTION: fromTimeString 0005 % 0006 % DESCRIPTION: Construct a time object from a string value 0007 % 0008 % CALL: tt = fromTimeString(tt, plist) 0009 % 0010 % INPUT: tt: input time object 0011 % plist: plist object which must contain the key 'time_str' 0012 % 0013 % EXAMPLES: Some examples for the value of the key 'time_str' 0014 % '2008-06-29 14:00:00.000' 0015 % '14:00:00.000 2008-06-29' 0016 % '14:00:00 29-06-2008' 0017 % '14:00:00' 0018 % 0019 % HISTORY: 07-05-2007 Hewitson 0020 % Creation 0021 % 0022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0023 0024 function varargout = fromTimeString(varargin) 0025 0026 if nargin ~= 2 0027 error('### Unknown number of inputs.'); 0028 end 0029 0030 % Get inputs 0031 tt = varargin{1}; 0032 pli = varargin{2}; 0033 0034 %%% decide whether we modify the time-object, or create a new one. 0035 tt = copy(tt, nargout); 0036 0037 % Get the default plist 0038 def_pl = time.getInfo('time', 'From Time String').plists; 0039 0040 % combine input-plist and default-plist 0041 pl = combine(pli, def_pl); 0042 0043 % set values 0044 tt.setTimeformat(find(pl, 'timeformat'), 'internal'); 0045 tt.setTimezone (find(pl, 'timezone'), 'internal'); 0046 tt.setTime_str (find(pl, 'time_str'), 'internal'); 0047 0048 % Sets again the user defined timeformat 0049 if find(pli, 'timeformat') 0050 tt.setTimeformat(find(pli, 'timeformat'), 'internal'); 0051 end 0052 0053 varargout{1} = tt;