Given seconds like 11728, write the smallest javascript function that returns a string like 3hrs. 15min. 28sec.
signature textTime([int] t,[bool] z,[bool] m)
t
is the time like 11728 and you can assume int
z
is optional and true means drop zero times, so 3hrs. 0min. 28sec.
becomes 3hrs. 28sec.
m
is optional and true means show only up to minutes, so 3hrs. 16min. 48sec.
is 3hrs. 16min.
For 1 hour, 1hrs.
is fine (vs 1hr.
)
Example:
textTime(11728) returns "3hrs. 0min. 28sec."
textTime(11728,true) returns "3hrs. 28sec."
textTime(11728,true,true) returns "3hrs."
Regex is fine, speed is inconsequential.
Shortest code wins.