Hello!
I would like a String from seconds that uses the appropriate locale for the user. I'm using Duration like this:
let localFormattedTime = duration.formatted(
.time(pattern: .minuteSecond(padMinuteToLength: 1))
.locale(.current)
)
print(localFormattedTime)
// prints: 1:15
This is the wrong delimiter for my region, it should show 1.15
.
In order to confirm that my locale was being read correctly I tested with a Date():
let timeFormatter = DateFormatter()
timeFormatter.dateStyle = .none
timeFormatter.timeStyle = .short
timeFormatter.locale = .current
let timeString = timeFormatter.string(from: time)
print(timeString)
// prints: 15.18
This is the correct delimiter as expected however I want to format from seconds not a Date().
What am I doing wrong? Any guidance will be much appreciated 😃
Hi @kattegattet , thank you so much for bringing that to attention. Date actually has a struct called ISO8601FormatStyle which allows you to change the time separator. There is some sample code at the bottom of the documentation I linked that shows this. I do not believe that Duration or TimeInterval has this capability, so please file a feedback report to get that added at https://feedbackassistant.apple.com and add the FB number here so that I can follow up with it.