PLUS overloads + operator for time objects. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: PLUS overloads + operator for time objects. This function adds a time in seconds to a time object. It is possible to define the addend as a string, a vector of numbers, an ao containing a vector of numbers, or a time object. CALL: t2 = t1 + value (in seconds) sec = t1 + t2; EXAMPLES: >> t1 = time('2007-07-01 12:23:33'); >> t2 = t1 + [30 2330]; >> t2 = t1 + '30'; >> t2 = t1 + ao(plist('vals',[30 2330])); >> seconds = t1 + t2; M-FILE INFO: Get information about this methods by calling >> time.getInfo('plus') Get information about a specified set-plist by calling: >> time.getInfo('plus', 'set') VERSION: $Id: plus.m,v 1.15 2008/09/04 15:29:31 ingo Exp $ HISTORY: 03-08-2007 Diepholz Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % PLUS overloads + operator for time objects. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: PLUS overloads + operator for time objects. 0005 % This function adds a time in seconds to a time object. 0006 % It is possible to define the addend as a string, 0007 % a vector of numbers, an ao containing a vector of numbers, 0008 % or a time object. 0009 % 0010 % CALL: t2 = t1 + value (in seconds) 0011 % sec = t1 + t2; 0012 % 0013 % EXAMPLES: >> t1 = time('2007-07-01 12:23:33'); 0014 % >> t2 = t1 + [30 2330]; 0015 % >> t2 = t1 + '30'; 0016 % >> t2 = t1 + ao(plist('vals',[30 2330])); 0017 % >> seconds = t1 + t2; 0018 % 0019 % M-FILE INFO: Get information about this methods by calling 0020 % >> time.getInfo('plus') 0021 % 0022 % Get information about a specified set-plist by calling: 0023 % >> time.getInfo('plus', 'set') 0024 % 0025 % VERSION: $Id: plus.m,v 1.15 2008/09/04 15:29:31 ingo Exp $ 0026 % 0027 % HISTORY: 03-08-2007 Diepholz 0028 % Creation 0029 % 0030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0031 0032 function varargout = plus(varargin) 0033 0034 %%% Check if this is a call for parameters 0035 if utils.helper.isinfocall(varargin{:}) 0036 varargout{1} = getInfo(varargin{3}); 0037 return 0038 end 0039 0040 %%% Collects the input values 0041 t1 = varargin{1}; 0042 t2 = varargin{2}; 0043 0044 %%% decide whether we modify the time-object, or create a new one. 0045 t1 = copy(t1, nargout); 0046 0047 %%%%% >> t2 = t1 + ao(30); %%%%% 0048 if isa(t2, 'ao') 0049 t2 = t2.data.y; 0050 end 0051 0052 %%%%% >> t2 = t1 + '30'; %%%%% 0053 if ischar(t2) 0054 t2 = str2double(t2); 0055 end 0056 0057 %%%%% >> t2 = t1 + 30; %%%%% 0058 if isnumeric(t2) 0059 0060 % Loop over the list of inputs 0061 for jj = 1 : length(t1) 0062 t1(jj).setEpochtime(t1(jj).utc_epoch_milli + t2*1000, 'internal'); 0063 end 0064 res = t1; 0065 0066 %%%%% >> number = t1 + t2; %%%%% 0067 elseif isa(t2, 'time') 0068 res = t1.utc_epoch_milli + t2.utc_epoch_milli; 0069 else 0070 error ('### Unknown plus-operation to a time object.'); 0071 end 0072 0073 varargout{1} = res; 0074 end 0075 0076 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0077 % Local Functions % 0078 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0079 0080 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0081 % 0082 % FUNCTION: getInfo 0083 % 0084 % DESCRIPTION: Get Info Object 0085 % 0086 % HISTORY: 11-07-07 M Hewitson 0087 % Creation. 0088 % 0089 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0090 0091 function ii = getInfo(varargin) 0092 if nargin == 1 && strcmpi(varargin{1}, 'None') 0093 sets = {}; 0094 pl = []; 0095 else 0096 sets = {'Default'}; 0097 pl = getDefaultPlist; 0098 end 0099 % Build info object 0100 ii = minfo(mfilename, 'time', '', utils.const.categories.aop, '$Id: plus.m,v 1.15 2008/09/04 15:29:31 ingo Exp $', sets, pl); 0101 end 0102 0103 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0104 % 0105 % FUNCTION: getDefaultPlist 0106 % 0107 % DESCRIPTION: Get Default Plist 0108 % 0109 % HISTORY: 11-07-07 M Hewitson 0110 % Creation. 0111 % 0112 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0113 0114 function plo = getDefaultPlist() 0115 plo = plist(); 0116 end 0117