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 { ...@@ -55,13 +55,12 @@ class MainTableViewController: UITableViewController {
cell.nameLabel.text = facility.name cell.nameLabel.text = facility.name
let open = Utilities.isOpen(facility: facility); let open = Utilities.isOpen(facility: facility);
if(indexPath.row >= 0){
if(open == true){ if(open == true){
cell.openClosedLabel.text="Open" cell.openClosedLabel.text="Open"
}else{ }else{
cell.openClosedLabel.text="Closed" cell.openClosedLabel.text="Closed"
} }
}
self.reloadInputViews() self.reloadInputViews()
return cell return cell
} }
......
...@@ -16,15 +16,25 @@ class Utilities: NSObject { ...@@ -16,15 +16,25 @@ class Utilities: NSObject {
let currentDay = getDayOfWeek() let currentDay = getDayOfWeek()
let time = getCurrentTime() let time = getCurrentTime()
let currentTime = time
if(facility.mainSchedule.openTimes.isEmpty || facility.mainSchedule.openTimes.count < currentDay!){ let day = currentDay
return false var open:Bool = false
} else { if(!facility.mainSchedule.openTimes.isEmpty){
if(time >= facility.mainSchedule.openTimes[currentDay!].startTime && time <= facility.mainSchedule.openTimes[currentDay!].endTime){ for i in 0 ..< facility.mainSchedule.openTimes.count{
return true
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? { static func getDayOfWeek()->Int? {
...@@ -39,7 +49,7 @@ class Utilities: NSObject { ...@@ -39,7 +49,7 @@ class Utilities: NSObject {
static func getCurrentTime() -> Date { static func getCurrentTime() -> Date {
let date = Date() let date = Date()
let dateFormatter = DateFormatter() let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US") dateFormatter.locale = Locale(identifier: "ET")
dateFormatter.dateFormat = "HH:mm:ss" dateFormatter.dateFormat = "HH:mm:ss"
let convertedDate = dateFormatter.string(from: date) let convertedDate = dateFormatter.string(from: date)
let currentDay = dateFormatter.date(from: convertedDate) 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