0001 function txt = display(t_span, varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 VERSION = '$Id: display.html,v 1.12 2008/03/31 10:27:39 hewitson Exp $';
0022 CATEGORY = 'Output';
0023
0024
0025 if nargin == 2
0026 if isa(t_span, 'timespan') && ischar(varargin{1})
0027 in = char(varargin{1});
0028 if strcmp(in, 'Params')
0029 txt = plist;
0030 return
0031 elseif strcmp(in, 'Version')
0032 txt = VERSION;
0033 return
0034 elseif strcmp(in, 'Category')
0035 txt = CATEGORY;
0036 return
0037 end
0038 end
0039 end
0040
0041 txt = {};
0042
0043 for ii = 1:numel(t_span)
0044 t = t_span(ii);
0045
0046 b_banner = sprintf('---------- timespan %02d ----------', ii);
0047 txt{end+1} = b_banner;
0048 txt{end+1} = ' ';
0049
0050 fields = fieldnames(t);
0051 max_length = length(fields{1});
0052 for jj = 2:length(fields)
0053 if length(fields{jj}) > max_length
0054 max_length = length(fields{jj});
0055 end
0056 end
0057
0058 for jj = 1:length(fields)
0059 field = fields{jj};
0060
0061 str_field = [];
0062 str_field(1:max_length-length(field)) = ' ';
0063 str_field = [field str_field];
0064
0065
0066 if strcmp(field, 'created')
0067 txt{end+1} = ' ';
0068 end
0069
0070
0071 if isnumeric(t.(field))
0072 txt{end+1} = sprintf ('%s: %s',str_field, num2str(t.(field)));
0073
0074
0075 elseif ischar(t.(field))
0076 txt{end+1} = sprintf ('%s: %s',str_field, t.(field));
0077
0078
0079 elseif islogical(t.(field))
0080 if t.(field) == true
0081 txt{end+1} = sprintf ('%s: true',str_field);
0082 else
0083 txt{end+1} = sprintf ('%s: false',str_field);
0084 end
0085
0086
0087 elseif isobject(t.(field))
0088 if isa(t.(field), 'time') || isa(t.(field), 'timeformat')
0089 txt{end+1} = sprintf ('%s: %s',str_field, char(t.(field)));
0090 else
0091 txt{end+1} = sprintf ('%s: %s class',str_field, class(t.(field)));
0092 end
0093
0094
0095 elseif isjava(t.(field))
0096 if strcmp(class(t.(field)), 'sun.util.calendar.ZoneInfo')
0097 EE = java.text.SimpleDateFormat('Z');
0098 EE.setTimeZone(t.(field))
0099 zone_id = t.(field).getID;
0100 if strcmp(zone_id, 'UTC')
0101 txt{end+1} = sprintf ('%s: %s',str_field, char(t.(field).getID));
0102 else
0103 txt{end+1} = sprintf ('%s: %s (UTC%s)',str_field, char(t.(field).getID), char(EE.format(t_span.start.utc_epoch_milli)));
0104 end
0105 else
0106 error ('### Unknown java class %s', class(t.(field)))
0107 end
0108
0109 else
0110 error ('### Please define the output for this property %s', field)
0111 end
0112
0113 end
0114
0115
0116 e_banner(1:length(b_banner)) = '-';
0117 txt{end+1} = e_banner;
0118
0119 txt{end+1} = ' ';
0120 txt{end+1} = ' ';
0121
0122 end
0123
0124 if nargout == 0
0125 for ii=1:length(txt)
0126 disp(txt{ii});
0127 end
0128 end
0129
0130
0131
0132