'Best way to work with store hours in Swift
I'm building an app in Swift that will take in a store's hours from Firebase and want to represent it in my code as something like "monday.close" to get 02:30. What's the best way to do something like this? Pic below is what the data looks like in Firebase.

init(dictionary: [String: Any]) {
//initialize food item here
self.name = dictionary["name"] as? String ?? ""
self.address = dictionary["address"] as? String ?? ""
self.restaurantLogo = UIImage(named: "")
self.menuItems = dictionary["menuItems"] as? [Food] ?? []
self.deliverUberEats = dictionary["uberEatsLink"] as? String ?? ""
self.deliverDoorDash = dictionary["doordashLink"] as? String ?? ""
self.deliverGrubhub = dictionary["grubhubLink"] as? String ?? ""
self.restaurantID = ""
self.priceRange = dictionary["price"] as? Int ?? 0
self.hoursOpen = dictionary["hours"] as? [String : [String: String]]
}
struct RestaurantHours {
var MonOpen: Date?
var MonClose: Date?
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
