Commit 513b96ef authored by Eyad Hasan's avatar Eyad Hasan
Browse files

I will finalize tomorrow, but the structure code for getting the app to...

I will finalize tomorrow, but the structure code for getting the app to display whats open is basically in place, it's a matter of fixing a bug I'm having and cleaning it up and making it more elegant.
parent a3baf8e6
......@@ -55,13 +55,12 @@ class MainTableViewController: UITableViewController {
cell.nameLabel.text = facility.name
let open = Utilities.isOpen(facility: facility);
if(indexPath.row >= 0){
if(open == true){
cell.openClosedLabel.text="Open"
}else{
cell.openClosedLabel.text="Closed"
}
}
self.reloadInputViews()
return cell
}
......
......@@ -16,15 +16,25 @@ class Utilities: NSObject {
let currentDay = getDayOfWeek()
let time = getCurrentTime()
if(facility.mainSchedule.openTimes.isEmpty || facility.mainSchedule.openTimes.count < currentDay!){
return false
} else {
if(time >= facility.mainSchedule.openTimes[currentDay!].startTime && time <= facility.mainSchedule.openTimes[currentDay!].endTime){
return true
let currentTime = time
let day = currentDay
var open:Bool = false
if(!facility.mainSchedule.openTimes.isEmpty){
for i in 0 ..< facility.mainSchedule.openTimes.count{
if(day! >= facility.mainSchedule.openTimes[i].startDay || day! <= facility.mainSchedule.openTimes[i].endDay){
if(currentTime >= facility.mainSchedule.openTimes[i].startTime && currentTime <= facility.mainSchedule.openTimes[i].endTime){
open = true
return open
}else{
open = false
}
}
}
}
return true
return open
}
static func getDayOfWeek()->Int? {
......@@ -39,7 +49,7 @@ class Utilities: NSObject {
static func getCurrentTime() -> Date {
let date = Date()
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US")
dateFormatter.locale = Locale(identifier: "ET")
dateFormatter.dateFormat = "HH:mm:ss"
let convertedDate = dateFormatter.string(from: date)
let currentDay = dateFormatter.date(from: convertedDate)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment