Home > classes > @timespan > computeInterval.m

computeInterval

PURPOSE ^

COMPUTEINTERVAL compute the interval of the time span.

SYNOPSIS ^

function ts = computeInterval(ts)

DESCRIPTION ^

 COMPUTEINTERVAL compute the interval of the time span.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: COMPUTE_INTERVAL compute the interval of the time span.

 CALL:        t1 = compute_interval(t1)

 VERSION:     $Id: computeInterval.m,v 1.1 2008/07/23 17:31:56 ingo Exp $

 HISTORY:     03-08-2007 Diepholz
                 Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % COMPUTEINTERVAL compute the interval of the time span.
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: COMPUTE_INTERVAL compute the interval of the time span.
0005 %
0006 % CALL:        t1 = compute_interval(t1)
0007 %
0008 % VERSION:     $Id: computeInterval.m,v 1.1 2008/07/23 17:31:56 ingo Exp $
0009 %
0010 % HISTORY:     03-08-2007 Diepholz
0011 %                 Creation
0012 %
0013 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0014 
0015 function ts = computeInterval(ts)
0016 
0017   ts.interval = '';
0018 
0019   number = abs(ts.startT.utc_epoch_milli-ts.endT.utc_epoch_milli);
0020 
0021   if (ts.endT.utc_epoch_milli-ts.startT.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.applyPattern('yyyy')
0029   num_y = char(form.format(java.util.Date(number)));
0030   num_y = str2double(num_y);
0031   num_y = num_y - 1970;
0032   num_y = sprintf('%02d', num_y);
0033 
0034   form.applyLocalizedPattern('DD')
0035   num_d = char(form.format(java.util.Date(number)));
0036   num_d = sprintf('%02d', str2double(num_d)-1);
0037 
0038   form.applyLocalizedPattern('HH')
0039   num_h = char(form.format(java.util.Date(number)));
0040 
0041   form.applyLocalizedPattern('mm')
0042   num_m = char(form.format(java.util.Date(number)));
0043 
0044   form.applyLocalizedPattern('ss')
0045   num_s = char(form.format(java.util.Date(number)));
0046 
0047   form.applyLocalizedPattern('SSS')
0048   num_milli_s = char(form.format(java.util.Date(number)));
0049 
0050   if ~strcmp(num_y, '00')
0051     ts.interval = [ts.interval num_y ' Years '];
0052   end
0053 
0054   if ~strcmp(num_d, '00')
0055     ts.interval = [ts.interval num_d ' Days '];
0056   end
0057 
0058   if ~strcmp(num_h, '00')
0059     ts.interval = [ts.interval num_h ' Hours '];
0060   end
0061 
0062   if ~strcmp(num_m, '00')
0063     ts.interval = [ts.interval num_m ' Minutes '];
0064   end
0065 
0066   if ~strcmp(num_s, '00')
0067     ts.interval = [ts.interval num_s ' Seconds '];
0068   end
0069 
0070   if ~strcmp(num_milli_s, '000')
0071     ts.interval = [ts.interval num_milli_s ' Milliseconds '];
0072   end
0073 end
0074 
0075

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003