Home > classes > @time > display.m

display

PURPOSE ^

DISPLAY display a time object.

SYNOPSIS ^

function display(tt)

DESCRIPTION ^

 DISPLAY display a time object.

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

 DESCRIPTION: DISPLAY display a time object.

 VERSION:     $Id: display.m,v 1.4 2007/08/07 13:53:04 ingo Exp $

 HISTORY:     23-07-2007 Diepholz
                 Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function display(tt)
0002 % DISPLAY display a time object.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: DISPLAY display a time object.
0007 %
0008 % VERSION:     $Id: display.m,v 1.4 2007/08/07 13:53:04 ingo Exp $
0009 %
0010 % HISTORY:     23-07-2007 Diepholz
0011 %                 Creation
0012 %
0013 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0014 
0015 txt = {};
0016 
0017 tt = reshape(tt, numel(tt), 1);
0018 
0019 for ii = 1:length(tt)
0020   t = tt(ii);
0021 
0022   b_banner = sprintf('---------- time %02d ----------', ii);
0023   txt{end+1} = b_banner;
0024   txt{end+1} = ' ';
0025 
0026   fields = fieldnames(t);
0027   max_length = length(fields{1});
0028   for jj = 2:length(fields)
0029     if length(fields{jj}) > max_length
0030       max_length = length(fields{jj});
0031     end
0032   end
0033 
0034   for jj = 1:length(fields)
0035     field = fields{jj};
0036 
0037     str_field = [];
0038     str_field(1:max_length-length(field)) = ' ';
0039     str_field = [field str_field];
0040 
0041     % Display: Number
0042     if isnumeric(t.(field))
0043       txt{end+1} = sprintf ('%s: %s',str_field, num2str(t.(field)));
0044 
0045     % Display: Strings
0046     elseif ischar(t.(field))
0047       txt{end+1} = sprintf ('%s: %s',str_field, t.(field));
0048 
0049     % Display: Logicals
0050     elseif islogical(t.(field))
0051       if t.(field) == true
0052         txt{end+1} = sprintf ('%s: true',str_field);
0053       else
0054         txt{end+1} = sprintf ('%s: false',str_field);
0055       end
0056 
0057     % Display: Objects
0058     elseif isobject(t.(field))
0059       if isa(t.(field), 'timeformat')
0060         txt{end+1} = sprintf ('%s: %s',str_field, char(t.(field)));
0061       else
0062         txt{end+1} = sprintf ('%s: %s class',str_field, class(t.(field)));
0063       end
0064 
0065     % Display: Java Objects
0066     elseif isjava(t.(field))
0067       if strcmp(class(t.(field)), 'sun.util.calendar.ZoneInfo')
0068         EE = java.text.SimpleDateFormat('Z');
0069         EE.setTimeZone(t.(field))
0070         zone_id = t.(field).getID;
0071         if strcmp(zone_id, 'UTC')
0072           txt{end+1} = sprintf ('%s: %s',str_field, char(t.(field).getID));
0073         else
0074           txt{end+1} = sprintf ('%s: %s (UTC%s)',str_field, char(t.(field).getID), char(EE.format(t.utc_epoch_milli)));
0075         end
0076       else
0077         error ('### Unknown java class %s', class(t.(field)))
0078       end
0079 
0080     else
0081       error ('### Please define the output for this property %s', field)
0082     end
0083 
0084   end
0085 
0086 
0087   e_banner(1:length(b_banner)) = '-';
0088   txt{end+1} = e_banner;
0089 
0090   txt{end+1} = ' ';
0091   txt{end+1} = ' ';
0092 
0093 end
0094 
0095 if nargout == 0
0096   for ii=1:length(txt)
0097     disp(txt{ii});
0098   end
0099 end
0100 
0101

Generated on Mon 03-Sep-2007 12:12:34 by m2html © 2003