Home > classes > @time > plus.m

plus

PURPOSE ^

PLUS overloads + operator for time objects.

SYNOPSIS ^

function res = plus(varargin)

DESCRIPTION ^

 PLUS overloads + operator for time objects.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: PLUS overloads + operator for analysis 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;

 VERSION:     $Id: plus.m,v 1.10 2008/03/19 12:27:06 mauro Exp $

 HISTORY:     03-08-2007 Diepholz
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function res = plus(varargin)
0002 % PLUS overloads + operator for time objects.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: PLUS overloads + operator for analysis objects.
0007 %              This function adds a time in seconds to a time object.
0008 %              It is possible to define the addend as a string,
0009 %              a vector of numbers, an ao containing a vector of numbers,
0010 %              or a time object.
0011 %
0012 % CALL:        t2  = t1 + value (in seconds)
0013 %              sec = t1 + t2;
0014 %
0015 % EXAMPLES:    >> t1      = time('2007-07-01 12:23:33');
0016 %              >> t2      = t1 +  [30 2330];
0017 %              >> t2      = t1 + '30';
0018 %              >> t2      = t1 + ao(plist('vals',[30 2330]));
0019 %              >> seconds = t1 + t2;
0020 %
0021 % VERSION:     $Id: plus.m,v 1.10 2008/03/19 12:27:06 mauro Exp $
0022 %
0023 % HISTORY:     03-08-2007 Diepholz
0024 %                 Creation
0025 %
0026 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0027 
0028 VERSION  = '$Id: plus.m,v 1.10 2008/03/19 12:27:06 mauro Exp $';
0029 CATEGORY = 'Arithmetic Operator';
0030 
0031 % 'Params' Call
0032 if nargin == 2
0033   if isa(varargin{1}, 'time') && ischar(varargin{2})
0034     in = char(varargin{2});
0035     if strcmp(in, 'Params')
0036       res = getDefaultPL;
0037       return
0038     elseif strcmp(in, 'Version')
0039       res = VERSION;
0040       return
0041     elseif strcmp(in, 'Category')
0042       res = CATEGORY;
0043       return
0044     end
0045   end
0046 end
0047 
0048 % Collects the input values
0049 t1 = varargin{1};
0050 t2 = varargin{2};
0051 
0052 %%%%%   >> t2 = t1 + ao(30);   %%%%%
0053 if isa(t2, 'ao')
0054   t2 = t2.data.y;
0055 end
0056 
0057 %%%%%   >> t2 = t1 + '30';   %%%%%
0058 if ischar(t2)
0059   t2 = str2double(t2);
0060 end
0061 
0062 %%%%%   >> t2 = t1 + 30;   %%%%%
0063 res = [];
0064 % Loop over the list of inputs
0065 if isnumeric(t2)
0066   tn = time;
0067   for jj = 1 : length(t2)
0068     res = [res;t1];
0069     res(jj) = set(res(jj), ...
0070       'utc_epoch_milli', t1.utc_epoch_milli + t2(jj)*1000, ...
0071       'created', tn.time_str);    
0072   end
0073 %%%%%   >> number = t1 + t2;   %%%%%
0074 elseif isa(t2, 'time')
0075   res = (t1-time(format(t1, 'yyyy-mm-dd'))) + (t2-time(format(t2, 'yyyy-mm-dd')));
0076 else
0077   error ('### Unknown plus-operation to a time object.');
0078 end
0079 
0080 
0081 
0082 
0083 %% Get default params
0084 function pl_default = getDefaultPL()
0085 
0086 pl_default = plist();
0087 
0088 % END

Generated on Mon 31-Mar-2008 13:54:54 by m2html © 2003