Home > classes > @timespan > private > compute_interval.m

compute_interval

PURPOSE ^

COMPUTE_INTERVAL compute the interval of the time span.

SYNOPSIS ^

function ts = compute_interval(ts)

DESCRIPTION ^

 COMPUTE_INTERVAL compute the interval of the time span.

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

 DESCRIPTION: COMPUTE_INTERVAL compute the interval of the time span.

 CALL:        t1 = compute_interval(t1)

 VERSION:     $Id: compute_interval.m,v 1.2 2007/11/12 13:41:41 ingo Exp $

 HISTORY:     03-08-2007 Diepholz
                 Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function ts = compute_interval(ts)
0002 % COMPUTE_INTERVAL compute the interval of the time span.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: COMPUTE_INTERVAL compute the interval of the time span.
0007 %
0008 % CALL:        t1 = compute_interval(t1)
0009 %
0010 % VERSION:     $Id: compute_interval.m,v 1.2 2007/11/12 13:41:41 ingo Exp $
0011 %
0012 % HISTORY:     03-08-2007 Diepholz
0013 %                 Creation
0014 %
0015 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0016 
0017 
0018 number = abs(ts.start.utc_epoch_milli-ts.end.utc_epoch_milli);
0019 
0020 form = java.text.SimpleDateFormat;
0021 form.setTimeZone(java.util.TimeZone.getTimeZone('UTC'));
0022 
0023 form.applyLocalizedPattern('DD')
0024 num_d = char(form.format(java.util.Date(number)));
0025 num_d = sprintf('%02d', str2num(num_d)-1);
0026 
0027 form.applyLocalizedPattern('HH')
0028 num_h = char(form.format(java.util.Date(number)));
0029 
0030 form.applyLocalizedPattern('mm')
0031 num_m = char(form.format(java.util.Date(number)));
0032 
0033 form.applyLocalizedPattern('ss')
0034 num_s = char(form.format(java.util.Date(number)));
0035 
0036 ts.interval = '';
0037 
0038 if ~strcmp(num_d, '00')
0039   ts.interval = [ts.interval num_d ' Days '];
0040 end
0041 
0042 if ~strcmp(num_h, '00')
0043   ts.interval = [ts.interval num_h ' Hours '];
0044 end
0045 
0046 if ~strcmp(num_m, '00')
0047   ts.interval = [ts.interval num_m ' Minutes '];
0048 end
0049 
0050 if ~strcmp(num_s, '00')
0051   ts.interval = [ts.interval num_s ' Seconds '];
0052 end
0053 
0054 
0055

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