


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,
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: plus.m,v 1.5 2008/01/14 20:03:53 ingo Exp $
HISTORY: 03-08-2007 Diepholz
Creation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

0001 function res = plus(t1,t2) 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 % 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: plus.m,v 1.5 2008/01/14 20:03:53 ingo Exp $ 0020 % 0021 % HISTORY: 03-08-2007 Diepholz 0022 % Creation 0023 % 0024 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0025 0026 VERSION = '$Id: plus.m,v 1.5 2008/01/14 20:03:53 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-time(format(t1, 'yyyy-mm-dd'))) + (t2-time(format(t2, 'yyyy-mm-dd'))); 0062 0063 % res = (t1.utc_epoch_milli + t2.utc_epoch_milli)/1000; 0064 0065 else 0066 error ('### Unknown plus-operation to a time object.'); 0067 end 0068 0069 0070 0071