-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMH.swift
60 lines (48 loc) · 1.92 KB
/
CMH.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// CMH.swift
// MFSMobile
// This is the CMH school class.
// Any school-specific functions/variables should go there.
// Be sure to override all the functions in the parent class.
// Created by 戴元平 on 1/15/19.
// Copyright © 2019 David. All rights reserved.
//
import Foundation
class CMH: School {
override init() {
super.init()
self.dayLetterList = "AB"
}
// MAINTAIN: This value must be updated every year.
// override func getMarkingPeriodID(quarter: Int) -> Int {
// if quarter == 1 {
// return 7215
// } else {
// return 7217
// }
// }
override func getClassDataAt(date: Date) -> [[String: Any]] {
//var period = period
listClasses = [[String: Any]]()
let formatter = DateFormatter()
formatter.dateFormat = "yyyyMMdd"
let dateString = formatter.string(from: date)
let path = FileList.classDate(date: dateString).filePath
guard let allClasses = NSArray(contentsOfFile: path) as? Array<Dictionary<String, Any>> else {
return listClasses
}
listClasses = allClasses
return listClasses
}
override func getClassDataAt(day: String) -> [[String: Any]] {
let dayDictPath = FileList.day.filePath
guard let dayDict = NSDictionary(contentsOfFile: dayDictPath) as? [String: String] else { return [[String: Any]]() }
let formatter = DateFormatter()
formatter.dateFormat = "yyyyMMdd"
let today = formatter.string(from: Date())
guard let date = dayDict.filter({ $0.value == day &&
(Int($0.key) ?? 0 ) > (Int(today) ?? 0) }).first?.key else { return [[String: Any]]() }
let schedulePath = FileList.classDate(date: date).filePath
return NSArray(contentsOfFile: schedulePath) as? [[String: Any]] ?? [[String: Any]]()
}
}