Commit 185229d4 authored by Eyad Hasan's avatar Eyad Hasan
Browse files

* Added the conversion code for the API

* Added some testing things, usually print statements to check if values are returning as expected.
* Will continue to add things to the isOpen function, soon it should be fully functional.
parent fcd94b81
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CD81F5181DC0334600009FBD"
BuildableName = "WhatsOpen.app"
BlueprintName = "WhatsOpen"
ReferencedContainer = "container:WhatsOpen.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7F4743171E11C7D100E6E3D1"
BuildableName = "WhatsOpenTests.xctest"
BlueprintName = "WhatsOpenTests"
ReferencedContainer = "container:WhatsOpen.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CD81F5181DC0334600009FBD"
BuildableName = "WhatsOpen.app"
BlueprintName = "WhatsOpen"
ReferencedContainer = "container:WhatsOpen.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CD81F5181DC0334600009FBD"
BuildableName = "WhatsOpen.app"
BlueprintName = "WhatsOpen"
ReferencedContainer = "container:WhatsOpen.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CD81F5181DC0334600009FBD"
BuildableName = "WhatsOpen.app"
BlueprintName = "WhatsOpen"
ReferencedContainer = "container:WhatsOpen.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
......@@ -54,6 +54,15 @@ class MainTableViewController: UITableViewController {
let facility = facilitiesArray[indexPath.row]
cell.nameLabel.text = facility.name
let open = Utilities.isOpen(facility: facility);
if(open == true)
{
// Label change is just for testing, we can adjust it later.
cell.openClosedLabel.text = "OPEN"
}else{
cell.openClosedLabel.text = "CLOSED"
}
return cell
}
......
......@@ -11,7 +11,7 @@ import UIKit
class SRCTNetworkController: NSObject {
public static func performDownload(completion: @escaping (_ result: Array<Facility>) -> Void) {
public static func performDownload(completion: @escaping (_ result: Array<Facility>) -> Void) {
let requestURL: NSURL = NSURL(string: "https://whatsopen.gmu.edu/api/facilities/?format=json")!
let urlRequest: NSMutableURLRequest = NSMutableURLRequest(url: requestURL as URL)
let session = URLSession.shared
......@@ -22,22 +22,23 @@ class SRCTNetworkController: NSObject {
let statusCode = httpResponse.statusCode
if (statusCode == 200) {
if let dataN = data {
if let dataN = data {
let json = try! JSONSerialization.jsonObject(with: dataN, options: []) as! Array<Any>
var facilities = Array<Facility>()
var facilities = Array<Facility>()
for f in json {
let fJson = f as! [String: Any]
if let facility = Facility(json: fJson) {
facilities.append(facility)
}
}
}
print(facilities)
//print(facilities)
completion(facilities)
}
......
......@@ -25,7 +25,4 @@ class SRCTSimpleTableViewCell: UITableViewCell {
// Configure the view for the selected state
}
}
......@@ -14,15 +14,27 @@ class Utilities: NSObject {
static func isOpen(facility: Facility) -> Bool {
let date = Date()
let date = getDayOfWeek()
// Swift has Sunday = 1, Python has Monday = 0.
// This fixes the issue, thanks to rhitt, should be incorporated into the function, but that's hard.
let pyDate = (5 + date!) % 7
print (pyDate)
//Testing
/**
print(facility.mainSchedule.openTimes[0].startTime)
print(facility.mainSchedule.openTimes[0].endTime)
print(facility.mainSchedule.openTimes[0].endDay)
print(facility.mainSchedule.openTimes[0].startDay)
**/
facility.mainSchedule.openTimes
return true;
}
static func getDayOfWeek()->Int? {
let todayDate = NSDate()
let myCalendar = NSCalendar(calendarIdentifier: NSCalendar.Identifier.gregorian)
......
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