0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 function varargout = display(varargin)
0026
0027
0028 if utils.helper.isinfocall(varargin{:})
0029 varargout{1} = getInfo(varargin{3});
0030 return
0031 end
0032
0033
0034 tt = utils.helper.collect_objects(varargin(:), 'time');
0035
0036 txt = {};
0037
0038 for ii = 1:numel(tt)
0039 t = tt(ii);
0040
0041 b_banner = sprintf('---------- time %02d ----------', ii);
0042 txt{end+1} = b_banner;
0043 txt{end+1} = ' ';
0044
0045 fields = fieldnames(t);
0046 max_length = length(fields{1});
0047 for jj = 2:length(fields)
0048 if length(fields{jj}) > max_length
0049 max_length = length(fields{jj});
0050 end
0051 end
0052
0053 for jj = 1:length(fields)
0054 field = fields{jj};
0055
0056 str_field = [];
0057 str_field(1:max_length-length(field)) = ' ';
0058 str_field = [field str_field];
0059
0060
0061
0062 if strcmp(field, 'time_str')
0063 time_str = time.epoch2str(t);
0064 txt{end+1} = sprintf ('%s: %s',str_field, time_str);
0065 continue
0066 end
0067
0068
0069 if strcmp(field, 'created')
0070 txt{end+1} = ' ';
0071 end
0072
0073
0074
0075 if strcmp(field, 'created')
0076 [time_str, created_str] = epoch2str(t);
0077 txt{end+1} = sprintf ('%s: %s',str_field, created_str);
0078 continue
0079 end
0080
0081
0082 if isnumeric(t.(field))
0083 txt{end+1} = sprintf ('%s: %s',str_field, num2str(t.(field)));
0084
0085
0086 elseif ischar(t.(field))
0087 txt{end+1} = sprintf ('%s: %s',str_field, t.(field));
0088
0089
0090 elseif islogical(t.(field))
0091 if t.(field) == true
0092 txt{end+1} = sprintf ('%s: true',str_field);
0093 else
0094 txt{end+1} = sprintf ('%s: false',str_field);
0095 end
0096
0097
0098 elseif isobject(t.(field))
0099 if isa(t.(field), 'timeformat') || isa(t.(field), 'plist')
0100 txt{end+1} = sprintf ('%s: %s',str_field, char(t.(field)));
0101 else
0102 txt{end+1} = sprintf ('%s: %s class',str_field, class(t.(field)));
0103 end
0104
0105
0106 elseif isjava(t.(field))
0107 if strcmp(class(t.(field)), 'sun.util.calendar.ZoneInfo')
0108 EE = java.text.SimpleDateFormat('Z');
0109 EE.setTimeZone(t.(field))
0110 zone_id = t.(field).getID;
0111 if strcmp(zone_id, 'UTC')
0112 txt{end+1} = sprintf ('%s: %s',str_field, char(t.(field).getID));
0113 else
0114 txt{end+1} = sprintf ('%s: %s (UTC%s)',str_field, char(t.(field).getID), char(EE.format(t.utc_epoch_milli)));
0115 end
0116 else
0117 error ('### Unknown java class %s', class(t.(field)))
0118 end
0119
0120 else
0121 error ('### Please define the output for this property %s', field)
0122 end
0123
0124 end
0125
0126 e_banner(1:length(b_banner)) = '-';
0127 txt{end+1} = e_banner;
0128
0129 txt{end+1} = ' ';
0130 txt{end+1} = ' ';
0131 end
0132
0133 if nargout == 0
0134 for ii=1:length(txt)
0135 disp(txt{ii});
0136 end
0137 end
0138
0139 varargout{1} = txt;
0140 end
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157 function ii = getInfo(varargin)
0158 if nargin == 1 && strcmpi(varargin{1}, 'None')
0159 sets = {};
0160 pl = [];
0161 else
0162 sets = {'Default'};
0163 pl = getDefaultPlist;
0164 end
0165
0166 ii = minfo(mfilename, 'time', '', utils.const.categories.output, '$Id: display.m,v 1.19 2008/09/04 15:29:31 ingo Exp $', sets, pl);
0167 end
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180 function plo = getDefaultPlist()
0181 plo = plist();
0182 end
0183