//
//  LiveData.swift
//  LeCountdown
//
//  Created by Laurent Morvillier on 03/02/2023.
//

import Foundation
import CoreData

struct LiveTimer: Identifiable, Comparable {
    var id: String
    var date: Date

    static func < (lhs: LiveTimer, rhs: LiveTimer) -> Bool {
        return lhs.date < rhs.date
    }
    
    func timer(context: NSManagedObjectContext) -> AbstractTimer? {
        return context.object(stringId: self.id) as? AbstractTimer
    }
    
    var ended: Bool {
        return self.date < Date()
    }
}
