duration.hms
duration: H = hms (D)
duration: [H, M] = hms (D)
duration: [H, M, S] = hms (D)
Split duration array into separate time unit values.
[H, M, S] = hms (D) splits the duration
array D into separate numeric arrays H, M, and S,
which correspond to hours, minutes, and seconds, respectively. Hours and
minutes are returned as whole numbers, while seconds may also have a
fractional part.
Each component is what truncating division leaves, so every one of them carries the sign of the duration as a whole and a span a hair under an hour reports 59 minutes rather than a whole one. Nothing is snapped to a whole unit and nothing is rounded to a fixed precision.
A duration that is not finite has no components to divide between: all
three take that same infinity, or NaN.
Source Code: duration
hms splits each duration into its hours, minutes and seconds as three separate numeric outputs.
d = duration (1, 30, 45)
d = duration 01:30:45
[h, m, s] = hms (d); [h, m, s]
ans =
1 30 45
Every component carries the sign of the duration as a whole, and the seconds keep their fraction on either side of zero.
d = duration (-4, -5, -6.5)
d = duration -04:05:06
[h, m, s] = hms (d); [h, m, s]
ans = -4.0000 -5.0000 -6.5000