Home > classes > @time > minus.m

minus

PURPOSE ^

MINUS overloads - operator for time objects.

SYNOPSIS ^

function res = minus(t1, t2)

DESCRIPTION ^

 MINUS overloads - operator for time objects.

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

 DESCRIPTION: MINUS overloads - operator for analysis objects.
              This function subtracts a time in seconds from a time object.
              It is possible to define the subtrahend as a string,
              number 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;
              >> t3      = t1 - '30';
              >> seconds = t1 - t2;

 VERSION:     $Id: minus.m,v 1.6 2008/02/15 16:26:08 mauro Exp $

 HISTORY:     03-08-2007 Diepholz
                 Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function res = minus(t1, t2)
0002 % MINUS overloads - operator for time objects.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: MINUS overloads - operator for analysis objects.
0007 %              This function subtracts a time in seconds from a time object.
0008 %              It is possible to define the subtrahend as a string,
0009 %              number or a time object.
0010 %
0011 % CALL:        t2  = t1 - value (in seconds)
0012 %              sec = t1 - t2;
0013 %
0014 % EXAMPLES:    >> t1      = time('2007-07-01 12:23:33');
0015 %              >> t2      = t1 - 30;
0016 %              >> t3      = t1 - '30';
0017 %              >> seconds = t1 - t2;
0018 %
0019 % VERSION:     $Id: minus.m,v 1.6 2008/02/15 16:26:08 mauro Exp $
0020 %
0021 % HISTORY:     03-08-2007 Diepholz
0022 %                 Creation
0023 %
0024 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0025 
0026 VERSION  = '$Id: minus.m,v 1.6 2008/02/15 16:26:08 mauro Exp $';
0027 CATEGORY = 'Arithmetic Operator';
0028 
0029 % 'Params' Call
0030 if nargin == 2
0031   if isa(t1, 'time') && ischar(t2)
0032     in = char(t2);
0033     if strcmp(in, 'Params')
0034       res = plist();
0035       return
0036     elseif strcmp(in, 'Version')
0037       res = VERSION;
0038       return
0039     elseif strcmp(in, 'Category')
0040       res = CATEGORY;
0041       return
0042     end
0043   end
0044 end
0045 
0046 if isnumeric(t2)
0047   t2 = ltpda_mat2str(t2);
0048 end
0049 
0050 %%%%%   >> t2 = t1 - 30;   %%%%%
0051 %%%%%   >> t2 = t1 - '30';   %%%%%
0052 if ischar(t2)
0053   java_format_str_seconds = 'ss';
0054 
0055   utc_timezone   = java.util.TimeZone.getTimeZone('UTC');
0056 
0057   t_format_seconds = java.text.SimpleDateFormat(java_format_str_seconds);
0058   t_format_seconds.setTimeZone(utc_timezone);
0059 
0060   epoch_time_seconds = t_format_seconds.parse(t2);
0061   epoch_time_seconds = epoch_time_seconds.getTime;
0062 
0063   res = set(t1, 'utc_epoch_milli', t1.utc_epoch_milli-epoch_time_seconds);
0064 
0065 %%%%%   >> number = t1 - t2;   %%%%%
0066 elseif isa(t2, 'time')
0067 
0068   res = (t1.utc_epoch_milli - t2.utc_epoch_milli)/1000;
0069 
0070 else
0071   error ('### Unknown minus-operation to a time object.');
0072 end
0073

Generated on Fri 07-Mar-2008 15:46:43 by m2html © 2003