Commit b102a35b authored by Patrick Murray's avatar Patrick Murray
Browse files

overnight stores should work now

parent 052f52ef
......@@ -8,6 +8,8 @@ target 'WhatsOpen' do
# pod 'RealmSwift'
# pod 'ObjectMapper+Realm', '~> 0.2'
# pod 'Segmentio', '~> 2.1'
end
......
PODFILE CHECKSUM: 8cdeebe37d18f2676d11d43e58932de7e69c0b04
PODFILE CHECKSUM: 3830d742aafcddf8897f50d296bb6ba37c44dc91
COCOAPODS: 1.0.0
COCOAPODS: 1.2.0
PODFILE CHECKSUM: 8cdeebe37d18f2676d11d43e58932de7e69c0b04
PODFILE CHECKSUM: 3830d742aafcddf8897f50d296bb6ba37c44dc91
COCOAPODS: 1.0.0
COCOAPODS: 1.2.0
......@@ -59,8 +59,13 @@ code_sign_if_enabled() {
if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
# Use the current code_sign_identitiy
echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\""
/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1"
local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'"
if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
code_sign_cmd="$code_sign_cmd &"
fi
echo "$code_sign_cmd"
eval "$code_sign_cmd"
fi
}
......@@ -82,3 +87,6 @@ strip_invalid_archs() {
fi
}
if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
wait
fi
......@@ -18,17 +18,14 @@ case "${TARGETED_DEVICE_FAMILY}" in
2)
TARGET_DEVICE_ARGS="--target-device ipad"
;;
3)
TARGET_DEVICE_ARGS="--target-device tv"
;;
*)
TARGET_DEVICE_ARGS="--target-device mac"
;;
esac
realpath() {
DIRECTORY="$(cd "${1%/*}" && pwd)"
FILENAME="${1##*/}"
echo "$DIRECTORY/$FILENAME"
}
install_resource()
{
if [[ "$1" = /* ]] ; then
......@@ -48,8 +45,8 @@ EOM
ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS}
;;
*.xib)
echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT}"
ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}"
echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}"
ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS}
;;
*.framework)
echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
......@@ -70,7 +67,7 @@ EOM
xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm"
;;
*.xcassets)
ABSOLUTE_XCASSET_FILE=$(realpath "$RESOURCE_PATH")
ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH"
XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE")
;;
*)
......@@ -93,7 +90,7 @@ then
# Find all other xcassets (this unfortunately includes those of path pods and other targets).
OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d)
while read line; do
if [[ $line != "`realpath $PODS_ROOT`*" ]]; then
if [[ $line != "${PODS_ROOT}*" ]]; then
XCASSET_FILES+=("$line")
fi
done <<<"$OTHER_XCASSETS"
......
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
FOUNDATION_EXPORT double Pods_WhatsOpenVersionNumber;
......
......@@ -178,13 +178,13 @@
isa = PBXNativeTarget;
buildConfigurationList = CD81F52B1DC0334600009FBD /* Build configuration list for PBXNativeTarget "WhatsOpen" */;
buildPhases = (
E4D10E984A4C70F84604BBA1 /* 📦 Check Pods Manifest.lock */,
E4D10E984A4C70F84604BBA1 /* [CP] Check Pods Manifest.lock */,
CD81F5151DC0334600009FBD /* Sources */,
CD81F5161DC0334600009FBD /* Frameworks */,
CD81F5171DC0334600009FBD /* Resources */,
CD81F53C1DC118AD00009FBD /* Embed Frameworks */,
E9916AC7EFA243AC1051DA5A /* 📦 Embed Pods Frameworks */,
E12D8B2421D5581CDD361A3A /* 📦 Copy Pods Resources */,
E9916AC7EFA243AC1051DA5A /* [CP] Embed Pods Frameworks */,
E12D8B2421D5581CDD361A3A /* [CP] Copy Pods Resources */,
);
buildRules = (
);
......@@ -259,14 +259,14 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
E12D8B2421D5581CDD361A3A /* 📦 Copy Pods Resources */ = {
E12D8B2421D5581CDD361A3A /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "📦 Copy Pods Resources";
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
......@@ -274,29 +274,29 @@
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-WhatsOpen/Pods-WhatsOpen-resources.sh\"\n";
showEnvVarsInLog = 0;
};
E4D10E984A4C70F84604BBA1 /* 📦 Check Pods Manifest.lock */ = {
E4D10E984A4C70F84604BBA1 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "📦 Check Pods Manifest.lock";
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
E9916AC7EFA243AC1051DA5A /* 📦 Embed Pods Frameworks */ = {
E9916AC7EFA243AC1051DA5A /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "📦 Embed Pods Frameworks";
name = "[CP] Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
......
......@@ -26,7 +26,11 @@ class MainTableViewController: UITableViewController {
SRCTNetworkController.performDownload { (facilities) in
self.facilitiesArray = facilities
self.tableView.reloadData()
print(self.facilitiesArray)
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}
......
......@@ -5,6 +5,37 @@ import Foundation
//
// MARK: - Data Model
//
struct OpenTimes: CreatableFromJSON { // TODO: Rename this struct
let endDay: Int
let endTime: Date
let id: Int
let lastModified: Date
let schedule: Int
let startDay: Int
let startTime: Date
init(endDay: Int, endTime: Date, id: Int, lastModified: Date, schedule: Int, startDay: Int, startTime: Date) {
self.endDay = endDay
self.endTime = endTime
self.id = id
self.lastModified = lastModified
self.schedule = schedule
self.startDay = startDay
self.startTime = startTime
}
init?(json: [String: Any]) {
guard let endDay = json["end_day"] as? Int else { return nil }
guard let endTime = Date(json: json, key: "end_time", format: "HH:mm:ss") else { return nil }
guard let id = json["id"] as? Int else { return nil }
guard let lastModified = Date(json: json, key: "last_modified", format: "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") else { return nil }
guard let schedule = json["schedule"] as? Int else { return nil }
guard let startDay = json["start_day"] as? Int else { return nil }
guard let startTime = Date(json: json, key: "start_time", format: "HH:mm:ss") else { return nil }
self.init(endDay: endDay, endTime: endTime, id: id, lastModified: lastModified, schedule: schedule, startDay: startDay, startTime: startTime)
}
}
struct Facility: CreatableFromJSON { // TODO: Rename this struct
let category: Any?
let id: Int
......@@ -56,34 +87,7 @@ struct Facility: CreatableFromJSON { // TODO: Rename this struct
guard let validStart = Date(json: json, key: "valid_start", format: "yyyy-MM-dd") else { return nil }
self.init(id: id, lastModified: lastModified, name: name, openTimes: openTimes, validEnd: validEnd, validStart: validStart)
}
struct OpenTimes: CreatableFromJSON { // TODO: Rename this struct
let endDay: Int
let endTime: Date
let id: Int
let lastModified: Date
let schedule: Int
let startDay: Int
let startTime: Date
init(endDay: Int, endTime: Date, id: Int, lastModified: Date, schedule: Int, startDay: Int, startTime: Date) {
self.endDay = endDay
self.endTime = endTime
self.id = id
self.lastModified = lastModified
self.schedule = schedule
self.startDay = startDay
self.startTime = startTime
}
init?(json: [String: Any]) {
guard let endDay = json["end_day"] as? Int else { return nil }
guard let endTime = Date(json: json, key: "end_time", format: "HH:mm:ss") else { return nil }
guard let id = json["id"] as? Int else { return nil }
guard let lastModified = Date(json: json, key: "last_modified", format: "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") else { return nil }
guard let schedule = json["schedule"] as? Int else { return nil }
guard let startDay = json["start_day"] as? Int else { return nil }
guard let startTime = Date(json: json, key: "start_time", format: "HH:mm:ss") else { return nil }
self.init(endDay: endDay, endTime: endTime, id: id, lastModified: lastModified, schedule: schedule, startDay: startDay, startTime: startTime)
}
}
}
struct SpecialSchedules: CreatableFromJSON { // TODO: Rename this struct
let id: Int
......@@ -109,34 +113,6 @@ struct Facility: CreatableFromJSON { // TODO: Rename this struct
guard let validStart = Date(json: json, key: "valid_start", format: "yyyy-MM-dd") else { return nil }
self.init(id: id, lastModified: lastModified, name: name, openTimes: openTimes, validEnd: validEnd, validStart: validStart)
}
struct OpenTimes: CreatableFromJSON { // TODO: Rename this struct
let endDay: Int
let endTime: Date
let id: Int
let lastModified: Date
let schedule: Int
let startDay: Int
let startTime: Date
init(endDay: Int, endTime: Date, id: Int, lastModified: Date, schedule: Int, startDay: Int, startTime: Date) {
self.endDay = endDay
self.endTime = endTime
self.id = id
self.lastModified = lastModified
self.schedule = schedule
self.startDay = startDay
self.startTime = startTime
}
init?(json: [String: Any]) {
guard let endDay = json["end_day"] as? Int else { return nil }
guard let endTime = Date(json: json, key: "end_time", format: "HH:mm:ss") else { return nil }
guard let id = json["id"] as? Int else { return nil }
guard let lastModified = Date(json: json, key: "last_modified", format: "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") else { return nil }
guard let schedule = json["schedule"] as? Int else { return nil }
guard let startDay = json["start_day"] as? Int else { return nil }
guard let startTime = Date(json: json, key: "start_time", format: "HH:mm:ss") else { return nil }
self.init(endDay: endDay, endTime: endTime, id: id, lastModified: lastModified, schedule: schedule, startDay: startDay, startTime: startTime)
}
}
}
}
......@@ -155,14 +131,14 @@ extension CreatableFromJSON {
guard let jsonDictionary = json[key] as? [String: Any] else { return nil }
self.init(json: jsonDictionary)
}
/// Attempts to produce an array of instances of the conforming type based on an array in the JSON dictionary.
/// - Returns: `nil` if the JSON array is missing or if there is an invalid/null element in the JSON array.
static func createRequiredInstances(from json: [String: Any], arrayKey: String) -> [Self]? {
guard let jsonDictionaries = json[arrayKey] as? [[String: Any]] else { return nil }
return createRequiredInstances(from: jsonDictionaries)
}
/// Attempts to produce an array of instances of the conforming type based on an array of JSON dictionaries.
/// - Returns: `nil` if there is an invalid/null element in the JSON array.
static func createRequiredInstances(from jsonDictionaries: [[String: Any]]) -> [Self]? {
......@@ -173,14 +149,14 @@ extension CreatableFromJSON {
}
return array
}
/// Attempts to produce an array of instances of the conforming type, or `nil`, based on an array in the JSON dictionary.
/// - Returns: `nil` if the JSON array is missing, or an array with `nil` for each invalid/null element in the JSON array.
static func createOptionalInstances(from json: [String: Any], arrayKey: String) -> [Self?]? {
guard let array = json[arrayKey] as? [Any] else { return nil }
return createOptionalInstances(from: array)
}
/// Attempts to produce an array of instances of the conforming type, or `nil`, based on an array.
/// - Returns: An array of instances of the conforming type and `nil` for each invalid/null element in the source array.
static func createOptionalInstances(from array: [Any]) -> [Self?] {
......@@ -205,17 +181,17 @@ extension Date {
formatter.dateFormat = format
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.calendar = Calendar(identifier: .gregorian)
formatter.timeZone = TimeZone(secondsFromGMT: 0)! // UTC is assumed, but won't interfere with a format-specified time zone.
formatter.timeZone = TimeZone(secondsFromGMT: NSTimeZone.local.secondsFromGMT())! // changed to be the user's local time.
formatterCache[format] = formatter
return formatter
}
static func parse(string: String, format: String) -> Date? {
var formatter: DateFormatter!
cacheQueue.sync { formatter = dateFormatter(with: format) }
return formatter.date(from: string)
}
init?(json: [String: Any], key: String, format: String) {
guard let string = json[key] as? String else { return nil }
guard let date = Date.parse(string: string, format: format) else { return nil }
......@@ -256,12 +232,12 @@ extension Array where Element: CustomStringConvertible {
}
return dateArray
}
func toURLArray() -> [URL]? {
var urlArray = [URL]()
for string in self {
guard let url = URL(string: String(describing: string)) else { return nil }
urlArray.append(url)
guard let url = URL(string: String(describing: string)) else { return nil }
urlArray.append(url)
}
return urlArray
}
......@@ -271,21 +247,21 @@ extension Array where Element: Any {
func toOptionalValueArray<Value>() -> [Value?] {
return map { ($0 is NSNull) ? nil : ($0 as? Value) }
}
func toOptionalDateArray(withFormat format: String) -> [Date?] {
return map { item in
guard let string = item as? String else { return nil }
return Date.parse(string: string, format: format)
}
}
func toOptionalDoubleArray() -> [Double?] {
return map { item in
guard let nsNumber = item as? NSNumber else { return nil }
return nsNumber.doubleValue
}
}
func toOptionalURLArray() -> [URL?] {
return map { item in
guard let string = item as? String else { return nil }
......
......@@ -15,28 +15,19 @@ class Utilities: NSObject {
static func isOpen(facility: Facility) -> Bool {
var open = false
if(specialSchedule(facility: facility) == true) {
}
if(!facility.mainSchedule.openTimes.isEmpty) {
let now = today(facility: facility)
if(now == true) {
let nowTime = time(facility: facility)
if let openDay = today(facility: facility) {
let nowTime = time(openTime: openDay)
if(nowTime == true) {
print(facility.mainSchedule.name ," open")
open = true
} else {
open = false
}
print("Same Day")
} else {
open = false
}
} else {
open = false
}
print(facility.mainSchedule.name ," is ", open)
return open
}
......@@ -59,29 +50,25 @@ class Utilities: NSObject {
return currentDay!
}
static func today(facility: Facility) -> Bool {
var today = false
static func today(facility: Facility) -> OpenTimes? {
let currentDay = getDayOfWeek()
let day = currentDay
for i in 0 ..< facility.mainSchedule.openTimes.count {
if(day! >= facility.mainSchedule.openTimes[i].startDay && day! <= facility.mainSchedule.openTimes[i].endDay) {
today = true
for openTime in facility.mainSchedule.openTimes {
if(day! >= openTime.startDay && day! <= openTime.endDay) {
return openTime
}
}
return today
return nil
}
static func time(facility: Facility) -> Bool {
static func time(openTime: OpenTimes) -> Bool {
var time = false
let currentTime = getCurrentTime()
let nowTime = currentTime
let nowTime = getCurrentTime()
for i in 0 ..< facility.mainSchedule.openTimes.count {
if(nowTime >= facility.mainSchedule.openTimes[i].startTime && nowTime <= facility.mainSchedule.openTimes[i].endTime) {
time = true
}
if(openTime.startTime >= openTime.endTime || nowTime >= openTime.startTime && nowTime <= openTime.endTime) {
time = true
}
return time
......@@ -99,16 +86,16 @@ class Utilities: NSObject {
}
}
// TODO: Function to check for special schedules?
// TODO: Function to check for special schedules?
//================== PAT LOOK HERE ==================
/** static func specialSchedule(facility: Facility) -> Bool {
var special = false
if(!(facility.specialSchedules!.openTimes.isEmpty)){
special = true
}
return special
} ================== PAT LOOK HERE ==================**/
/** static func specialSchedule(facility: Facility) -> Bool {
var special = false
if(!(facility.specialSchedules!.openTimes.isEmpty)){
special = true
}
return special
} ================== PAT LOOK HERE ==================**/
}
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