Skip to content

Instantly share code, notes, and snippets.

@fethica
Created November 18, 2020 21:11
Show Gist options
  • Save fethica/204c808408ecac89206024e74a842fa5 to your computer and use it in GitHub Desktop.
Save fethica/204c808408ecac89206024e74a842fa5 to your computer and use it in GitHub Desktop.
let duration = "44:18"
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "mm:ss"
let date = dateFormatter.date(from: duration)
let minutesComponents = Calendar.current.dateComponents([.minute, .second], from: date!)
let accessibilityLabel = DateComponentsFormatter.localizedString(from: minutesComponents, unitsStyle: .spellOut)
print(accessibilityLabel) // forty-four minutes, eighteen seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment