MINUS overloads - operator for time objects. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: MINUS overloads - operator for time objects. This function subtracts a time in seconds from a time object. It is possible to define the subtrahend 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 10]; >> t2 = t1 - '30'; >> t2 = t1 - ao(plist('vals',[30 10])); >> seconds = t1 - t2; M-FILE INFO: Get information about this methods by calling >> time.getInfo('minus') Get information about a specified set-plist by calling: >> time.getInfo('minus', 'set') VERSION: $Id: minus.m,v 1.12 2008/09/04 15:29:31 ingo Exp $ HISTORY: 03-08-2007 Diepholz Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % MINUS overloads - operator for time objects. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: MINUS overloads - operator for time objects. 0005 % This function subtracts a time in seconds from a time object. 0006 % It is possible to define the subtrahend 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 10]; 0015 % >> t2 = t1 - '30'; 0016 % >> t2 = t1 - ao(plist('vals',[30 10])); 0017 % >> seconds = t1 - t2; 0018 % 0019 % M-FILE INFO: Get information about this methods by calling 0020 % >> time.getInfo('minus') 0021 % 0022 % Get information about a specified set-plist by calling: 0023 % >> time.getInfo('minus', 'set') 0024 % 0025 % VERSION: $Id: minus.m,v 1.12 2008/09/04 15:29:31 ingo Exp $ 0026 % 0027 % HISTORY: 03-08-2007 Diepholz 0028 % Creation 0029 % 0030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0031 0032 function varargout = minus(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)/1000; 0069 else 0070 error ('### Unknown minus-operation to a time object.'); 0071 end 0072 0073 varargout{1} = res; 0074 0075 end 0076 0077 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0078 % Local Functions % 0079 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0080 0081 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0082 % 0083 % FUNCTION: getInfo 0084 % 0085 % DESCRIPTION: Get Info Object 0086 % 0087 % HISTORY: 11-07-07 M Hewitson 0088 % Creation. 0089 % 0090 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0091 0092 function ii = getInfo(varargin) 0093 if nargin == 1 && strcmpi(varargin{1}, 'None') 0094 sets = {}; 0095 pl = []; 0096 else 0097 sets = {'Default'}; 0098 pl = getDefaultPlist; 0099 end 0100 % Build info object 0101 ii = minfo(mfilename, 'time', '', utils.const.categories.aop, '$Id: minus.m,v 1.12 2008/09/04 15:29:31 ingo Exp $', sets, pl); 0102 end 0103 0104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0105 % 0106 % FUNCTION: getDefaultPlist 0107 % 0108 % DESCRIPTION: Get Default Plist 0109 % 0110 % HISTORY: 11-07-07 M Hewitson 0111 % Creation. 0112 % 0113 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0114 0115 function plo = getDefaultPlist() 0116 plo = plist(); 0117 end 0118