Enhanced formatTime() function by allowing to specify a minimum and
maximum time unit for the formatted string