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.3 2008/02/13 10:20:16 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.3 2008/02/13 10:20:16 ingo Exp $
0011 %
0012 % HISTORY:     03-08-2007 Diepholz
0013 %                 Creation
0014 %
0015 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0016 
0017 ts.interval = '';
0018 
0019 number = abs(ts.start.utc_epoch_milli-ts.end.utc_epoch_milli);
0020 
0021 if (ts.end.utc_epoch_milli-ts.start.utc_epoch_milli < 0)
0022   ts.interval = '-';
0023 end
0024 
0025 form = java.text.SimpleDateFormat;
0026 form.setTimeZone(java.util.TimeZone.getTimeZone('UTC'));
0027 
0028 form.applyLocalizedPattern('DD')
0029 num_d = char(form.format(java.util.Date(number)));
0030 num_d = sprintf('%02d', str2num(num_d)-1);
0031 
0032 form.applyLocalizedPattern('HH')
0033 num_h = char(form.format(java.util.Date(number)));
0034 
0035 form.applyLocalizedPattern('mm')
0036 num_m = char(form.format(java.util.Date(number)));
0037 
0038 form.applyLocalizedPattern('ss')
0039 num_s = char(form.format(java.util.Date(number)));
0040 
0041 form.applyLocalizedPattern('SSS')
0042 num_milli_s = char(form.format(java.util.Date(number)));
0043 
0044 if ~strcmp(num_d, '00')
0045   ts.interval = [ts.interval num_d ' Days '];
0046 end
0047 
0048 if ~strcmp(num_h, '00')
0049   ts.interval = [ts.interval num_h ' Hours '];
0050 end
0051 
0052 if ~strcmp(num_m, '00')
0053   ts.interval = [ts.interval num_m ' Minutes '];
0054 end
0055 
0056 if ~strcmp(num_s, '00')
0057   ts.interval = [ts.interval num_s ' Seconds '];
0058 end
0059 
0060 if ~strcmp(num_milli_s, '000')
0061   ts.interval = [ts.interval num_milli_s ' Milliseconds '];
0062 end
0063 
0064 
0065

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