Created
May 5, 2022 16:41
-
-
Save armstrongnate/054c7d5847344a43db6dbb8819b0d6e9 to your computer and use it in GitHub Desktop.
Default iOS Date Formats (to send to a designer)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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