If I have a duration variable with the display format 'hh:mm' then the time is truncated instead of rounded when displaying its value, e.g.
d = seconds(59); % Duration object for 59 secs, or 00:00:59 in hh:mm:ss format
d.Format = 'hh:mm';
disp(d)
>> d = 00:00
Is there any way to change the display format to round to the nearest display unit (in this case minutes) instead of truncating? In this example I'd expect to see d = 00:01.
Conversions to char or other display methods yield the same output, e.g. char(d) / fprintf('%s',d).
The only alternative I can see is some manual hack like
d2 = round(d,'minutes'); % >> 00:01:00
d2.Format = 'hh:mm'; % >> 00:01
disp(d2);
Note that I have to re-set the Format after rounding because it doesn't inherit the format from d.
I couldn't see this behaviour documented either way as "expected" in the docs, so in my opinion the current implementation seems like unexpected behaviour.