lib/duration: format duration in most appropriate unit