//
//  Calendar+TimeZone.swift
//  1Weather
//
//  Created by Dmitry Stepanets on 18.03.2021.
//

import UIKit

extension Calendar {
    static func timeZoneCalendar(timeZone:TimeZone) -> Self {
        var cal = Calendar(identifier: current.identifier)
        cal.timeZone = timeZone
        return cal
    }
    
    static func isNow(fromDate date:Date, timeZone:TimeZone) -> Bool {
        guard let nowDate = Date.nowDate(timeZone: timeZone) else {
            return false
        }
        return self.timeZoneCalendar(timeZone: timeZone).isDate(date, equalTo: nowDate, toGranularity: .hour)
    }
}
