Skip to content

Instantly share code, notes, and snippets.

@armstrongnate
Created May 5, 2022 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save armstrongnate/054c7d5847344a43db6dbb8819b0d6e9 to your computer and use it in GitHub Desktop.
Save armstrongnate/054c7d5847344a43db6dbb8819b0d6e9 to your computer and use it in GitHub Desktop.
Default iOS Date Formats (to send to a designer)
import Foundation
import SwiftUI
import CoreLocation
let jan = Calendar.current.date(from: DateComponents(year: 2021, month: 1, day: 1, hour: 2, minute: 0))!
let styles: [DateFormatter.Style] = [
.none,
.short,
.medium,
.long,
.full,
]
extension DateFormatter.Style {
var label: String {
switch self {
case .short: return "Short"
case .medium: return "Medium"
case .long: return "Long"
case .full: return "Full"
case .none: return "None"
}
}
}
let formatter = DateFormatter()
for dateStyle in styles {
for timeStyle in styles {
formatter.dateStyle = dateStyle
formatter.timeStyle = timeStyle
print(formatter.string(from: jan))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment