//
//  PlannedWorkout.swift
//  Werkout_ios
//
//  Created by Trey Tartt on 7/1/23.
//

import Foundation

struct PlannedWorkout: Codable {
    let id: Int
    let createdAt, updatedAt, onDate: String
    let workout: Workout
    
    enum CodingKeys: String, CodingKey {
        case id
        case createdAt = "created_at"
        case updatedAt = "updated_at"
        case onDate = "on_date"
        case workout
    }
    
    var date: Date? {
        let df = DateFormatter()
        df.dateFormat = "yyyy-MM-dd"
        df.locale = Locale(identifier: "en_US_POSIX")
        return df.date(from: self.onDate)
    }
}
