Last active
August 9, 2022 03:27
-
-
Save yycking/8b37985cd9618515459286424b7c438b to your computer and use it in GitHub Desktop.
swift TimeZone list like setting
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 Cocoa | |
let formatter = DateFormatter() | |
formatter.dateStyle = .long | |
formatter.dateFormat = "(O) VVV" | |
formatter.locale = Locale(identifier: "zh") | |
TimeZone.knownTimeZoneIdentifiers | |
.compactMap(TimeZone.init(identifier:)) | |
.map { timeZone -> String in | |
formatter.timeZone = timeZone | |
return formatter.string(from: Date()) | |
}.forEach { | |
print($0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment