Fix Until format in RRule(), add comments to MeetingTime struct

This commit is contained in:
2024-01-28 05:59:45 -06:00
parent 3a54387881
commit 4ec69b0053

View File

@@ -28,31 +28,53 @@ type MeetingTimeResponse struct {
CourseReferenceNumber string `json:"courseReferenceNumber"` CourseReferenceNumber string `json:"courseReferenceNumber"`
Faculty []FacultyItem Faculty []FacultyItem
MeetingTime struct { MeetingTime struct {
Category string `json:"category"` Category string `json:"category"`
Class string `json:"class"` // Some sort of metadata used internally by Banner (net.hedtech.banner.student.schedule.SectionSessionDecorator)
StartDate string `json:"startDate"` Class string `json:"class"`
EndDate string `json:"endDate"` // The start date of the meeting time in MM/DD/YYYY format (e.g. 01/16/2024)
BeginTime string `json:"beginTime"` StartDate string `json:"startDate"`
EndTime string `json:"endTime"` // The end date of the meeting time in MM/DD/YYYY format (e.g. 05/10/2024)
Room string `json:"room"` EndDate string `json:"endDate"`
Term string `json:"term"` // The start time of the meeting time in 24-hour format, hours & minutes, digits only (e.g. 1630)
Building string `json:"building"` BeginTime string `json:"beginTime"`
BuildingDescription string `json:"buildingDescription"` // The end time of the meeting time in 24-hour format, hours & minutes, digits only (e.g. 1745)
Campus string `json:"campus"` EndTime string `json:"endTime"`
CampusDescription string `json:"campusDescription"` // The room number within the building this course takes place at (e.g. 3.01.08, 200A)
CourseReferenceNumber string `json:"courseReferenceNumber"` Room string `json:"room"`
CreditHourSession float64 `json:"creditHourSession"` // The internal identifier for the term this course takes place in (e.g. 202420)
HoursWeek float64 `json:"hoursWeek"` Term string `json:"term"`
MeetingScheduleType string `json:"meetingScheduleType"` // The internal identifier for the building this course takes place at (e.g. SP1)
MeetingType string `json:"meetingType"` Building string `json:"building"`
MeetingTypeDescription string `json:"meetingTypeDescription"` // The long name of the building this course takes place at (e.g. San Pedro I - Data Science)
Monday bool `json:"monday"` BuildingDescription string `json:"buildingDescription"`
Tuesday bool `json:"tuesday"` // The internal identifier for the campus this course takes place at (e.g. 1DT)
Wednesday bool `json:"wednesday"` Campus string `json:"campus"`
Thursday bool `json:"thursday"` // The long name of the campus this course takes place at (e.g. Main Campus, Downtown Campus)
Friday bool `json:"friday"` CampusDescription string `json:"campusDescription"`
Saturday bool `json:"saturday"` CourseReferenceNumber string `json:"courseReferenceNumber"`
Sunday bool `json:"sunday"` // The number of credit hours this class is worth (assumably)
CreditHourSession float64 `json:"creditHourSession"`
// The number of hours per week this class meets (e.g. 2.5)
HoursWeek float64 `json:"hoursWeek"`
MeetingScheduleType string `json:"meetingScheduleType"`
// The short identifier for the meeting type (e.g. FF, HB, OS, OA)
MeetingType string `json:"meetingType"`
// The long name of the meeting type (e.g. Traditional in-person)
MeetingTypeDescription string `json:"meetingTypeDescription"`
// A boolean indicating if the class will meet on each Monday of the term
Monday bool `json:"monday"`
// A boolean indicating if the class will meet on each Tuesday of the term
Tuesday bool `json:"tuesday"`
// A boolean indicating if the class will meet on each Wednesday of the term
Wednesday bool `json:"wednesday"`
// A boolean indicating if the class will meet on each Thursday of the term
Thursday bool `json:"thursday"`
// A boolean indicating if the class will meet on each Friday of the term
Friday bool `json:"friday"`
// A boolean indicating if the class will meet on each Saturday of the term
Saturday bool `json:"saturday"`
// A boolean indicating if the class will meet on each Sunday of the term
Sunday bool `json:"sunday"`
} `json:"meetingTime"` } `json:"meetingTime"`
Term string `json:"term"` Term string `json:"term"`
} }
@@ -152,7 +174,7 @@ func (m *MeetingTimeResponse) StartDay() time.Time {
return t return t
} }
// EndDay returns the end date of the meeting time as a time.Time object // EndDay returns the end date of the meeting time as a time.Time object.
// This is not cached and is parsed on each invocation. It may also panic without handling. // This is not cached and is parsed on each invocation. It may also panic without handling.
func (m *MeetingTimeResponse) EndDay() time.Time { func (m *MeetingTimeResponse) EndDay() time.Time {
t, err := time.Parse(layout, m.MeetingTime.EndDate) t, err := time.Parse(layout, m.MeetingTime.EndDate)
@@ -199,7 +221,7 @@ func (m *MeetingTimeResponse) RRule() string {
sb := strings.Builder{} sb := strings.Builder{}
sb.WriteString("FREQ=WEEKLY;") sb.WriteString("FREQ=WEEKLY;")
sb.WriteString(fmt.Sprintf("UNTIL=%s;", m.EndDay().Format("20060102"))) sb.WriteString(fmt.Sprintf("UNTIL=%s;", m.EndDay().UTC().Format(ICalTimestampFormatUtc)))
sb.WriteString(fmt.Sprintf("BYDAY=%s;", m.ByDay())) sb.WriteString(fmt.Sprintf("BYDAY=%s;", m.ByDay()))
return sb.String() return sb.String()