update date decoder
This commit is contained in:
@@ -23,6 +23,20 @@ public func configure(_ app: Application) throws {
|
||||
app.migrations.add(AddCODGame2())
|
||||
|
||||
|
||||
|
||||
// create a new JSON encoder that uses unix-timestamp dates
|
||||
let decoder = JSONDecoder()
|
||||
|
||||
let formatter = DateFormatter()
|
||||
formatter.calendar = Calendar(identifier: .iso8601)
|
||||
formatter.locale = Locale(identifier: "en_US_POSIX")
|
||||
formatter.timeZone = TimeZone(secondsFromGMT: 0)
|
||||
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
|
||||
decoder.dateDecodingStrategy = .formatted(formatter)
|
||||
|
||||
// override the global encoder used for the `.json` media type
|
||||
ContentConfiguration.global.use(decoder: decoder, for: .json)
|
||||
|
||||
// register routes
|
||||
try routes(app)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user