Home > classes > @time > display.m

display

PURPOSE ^

DISPLAY overloads display functionality for time objects.

SYNOPSIS ^

function txt = display(tt)

DESCRIPTION ^

 DISPLAY overloads display functionality for time objects.

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

 DESCRIPTION: DISPLAY overloads display functionality for time objects.

 CALL:        txt  = display(time)

 INPUT:       time - time object

 OUTPUT:      txt  - cell array with strings to display the time object

 VERSION:     $Id: display.m,v 1.5 2007/09/12 14:01:38 ingo Exp $

 HISTORY:     23-07-2007 Diepholz
                 Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

Generated on Fri 02-Nov-2007 19:39:27 by m2html © 2003