DateComponentsFormatter drop zero hours but not zero minutes
问题 I'm trying to use a DateComponentsFormatter to format a number of seconds into a time string HH:MM:SS. I always want to show the minutes and seconds fields but I don't want to show hours if hours is 0. I tried setting formatter.zeroFormattingBehavior = .dropLeading But, this causes the minutes to be dropped as well if both hours and minutes are 0. Currently, my solution is as follows: if timeElapsed >= 3600 { formatter.allowedUnits = [.second, .minute, .hour] } else { formatter.allowedUnits =