Last active
July 6, 2020 08:04
-
-
Save stevencurtis/a85e78e35b8fcf7545cf60ff26936ae3 to your computer and use it in GitHub Desktop.
isopropertywrapper
This file contains 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
@propertyWrapper | |
struct ISO8601DateFormatted { | |
static private let formatter = ISO8601DateFormatter() | |
var projectedValue: String { ISO8601DateFormatted.formatter.string(from: wrappedValue) } | |
var wrappedValue: Date | |
} | |
struct Form { | |
@ISO8601DateFormatted var createdAt: Date | |
} | |
let user = Form(createdAt: Date()) | |
user.createdAt // "Jul 6, 2020 at 8:56 AM" | |
user.$createdAt // "2020-07-06 07:56:24 +0000\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment