Post

Replies

Boosts

Views

Activity

Duration not using correct delimiter for locale
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 😃
3
0
444
Sep ’23