-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.go
57 lines (46 loc) · 1.11 KB
/
model.go
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
package cmscal
import "time"
type BlockDayType int
const (
BlueDay BlockDayType = iota
WhiteDay
NonBlockDay
ShortWednesday
)
func (t BlockDayType) String() string {
return []string{"BLUE DAY", "WHITE DAY", "DAILY SCHEDULE", "SHORT WEDNESDAY"}[t]
}
type ClassPeriod struct {
StartHour int
StartMinute int
Duration time.Duration
Description string
}
type DaySchedule []ClassPeriod
type GradeSchedule struct {
Name string
Description string
ScheduleMap map[BlockDayType]DaySchedule
}
type BuildingSchedule struct {
startDate time.Time
numWeekdays int
firstDayType BlockDayType
holidays map[time.Time]bool
// "I have altered our deal. Pray I do not alter it again."
nonBlockChangeDay time.Time
// Haha nothing matters
shortWednesdayChangeDay time.Time
}
func nextDayType(bs *BuildingSchedule, yesterday BlockDayType, today time.Time) BlockDayType {
if today.After(bs.shortWednesdayChangeDay) && today.Weekday() == time.Wednesday {
return ShortWednesday
}
if today.After(bs.nonBlockChangeDay) {
return NonBlockDay
}
if yesterday == WhiteDay {
return BlueDay
}
return WhiteDay
}