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.4 2008/01/14 20:03:52 ingo 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.4 2008/01/14 20:03:52 ingo Exp $
0020 %
0021 % HISTORY:     03-08-2007 Diepholz
0022 %                 Creation
0023 %
0024 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0025 
0026 VERSION  = '$Id: minus.m,v 1.4 2008/01/14 20:03:52 ingo Exp $';
0027 
0028 % 'Params' Call
0029 if nargin == 2
0030   if isa(t1, 'time') && strcmp(t2, 'Params')
0031     res = plist();
0032     return
0033   elseif isa(t1, 'time') && strcmp(t2, 'Version')
0034     res = VERSION;
0035     return
0036   end
0037 end
0038 
0039 if isnumeric(t2)
0040   t2 = ltpda_mat2str(t2);
0041 end
0042 
0043 %%%%%   >> t2 = t1 - 30;   %%%%%
0044 %%%%%   >> t2 = t1 - '30';   %%%%%
0045 if ischar(t2)
0046   java_format_str_seconds = 'ss';
0047 
0048   utc_timezone   = java.util.TimeZone.getTimeZone('UTC');
0049 
0050   t_format_seconds = java.text.SimpleDateFormat(java_format_str_seconds);
0051   t_format_seconds.setTimeZone(utc_timezone);
0052 
0053   epoch_time_seconds = t_format_seconds.parse(t2);
0054   epoch_time_seconds = epoch_time_seconds.getTime;
0055 
0056   res = set(t1, 'utc_epoch_milli', t1.utc_epoch_milli-epoch_time_seconds);
0057 
0058 %%%%%   >> number = t1 - t2;   %%%%%
0059 elseif isa(t2, 'time')
0060 
0061   res = (t1.utc_epoch_milli - t2.utc_epoch_milli)/1000;
0062 
0063 else
0064   error ('### Unknown minus-operation to a time object.');
0065 end
0066

Generated on Tue 22-Jan-2008 10:39:13 by m2html © 2003