Skip to content

Instantly share code, notes, and snippets.

@michaelevensen
Created April 17, 2023 12:44
Show Gist options
  • Save michaelevensen/2084e74017adf2691ee4c4b3dfd264d6 to your computer and use it in GitHub Desktop.
Save michaelevensen/2084e74017adf2691ee4c4b3dfd264d6 to your computer and use it in GitHub Desktop.
Date / duration formatting with the new `.formatted()` API in Swift.
Text((startDate..<endDate).formatted(.components(style: .wide)).capitalized)
Text(endDate.formatted(.relative(presentation: .numeric, unitsStyle: .spellOut)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment