Created
June 1, 2017 12:33
-
-
Save bartjacobs/1e53e9abd1ab46175141c9786d1e9e03 to your computer and use it in GitHub Desktop.
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
import Foundation | |
struct WeatherDayData { | |
let time: Date | |
let icon: String | |
let windSpeed: Double? | |
let temperatureMin: Double | |
let temperatureMax: Double | |
} | |
extension WeatherDayData: JSONDecodable { | |
init(decoder: JSONDecoder) throws { | |
self.icon = try decoder.decode(key: "icon") | |
self.windSpeed = try? decoder.decode(key: "windSpeed") | |
self.temperatureMin = try decoder.decode(key: "temperatureMin") | |
self.temperatureMax = try decoder.decode(key: "temperatureMax") | |
let time: Double = try decoder.decode(key: "time") | |
self.time = Date(timeIntervalSince1970: time) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment