include the after-break
This commit is contained in:
parent
8cb99e69af
commit
732f56f0be
1 changed files with 29 additions and 22 deletions
|
@ -242,33 +242,40 @@ pub fn build(timetable: T, dates: D) -> Vec<models::Course> {
|
||||||
let mut semester = Vec::new();
|
let mut semester = Vec::new();
|
||||||
|
|
||||||
// Start date of the back-to-school week
|
// Start date of the back-to-school week
|
||||||
let data = dates.get(&timetable.1 .0).unwrap().get(0).unwrap();
|
let break_data = dates.get(&timetable.1 .0).unwrap();
|
||||||
let mut date = data.0;
|
let before_break = break_data.get(0).unwrap();
|
||||||
|
let mut date = before_break.0;
|
||||||
|
let mut rep = before_break.1;
|
||||||
// For each weeks
|
// For each weeks
|
||||||
for _ in 0..(data.1) {
|
for _ in 0..2 {
|
||||||
for day in &timetable.1 .1 {
|
for _ in 0..rep {
|
||||||
for mut course in day.courses.clone().into_iter().flatten() {
|
for day in &timetable.1 .1 {
|
||||||
// Get the hours
|
for mut course in day.courses.clone().into_iter().flatten() {
|
||||||
let start = schedules.get(course.start).unwrap().0;
|
// Get the hours
|
||||||
// -1 because we only add when the size is > 1
|
let start = schedules.get(course.start).unwrap().0;
|
||||||
let end = schedules.get(course.start + course.size - 1).unwrap().1;
|
// -1 because we only add when the size is > 1
|
||||||
|
let end = schedules.get(course.start + course.size - 1).unwrap().1;
|
||||||
|
|
||||||
// Add the changed datetimes
|
// Add the changed datetimes
|
||||||
course.dtstart = Some(
|
course.dtstart = Some(
|
||||||
Utc.ymd(date.year(), date.month(), date.day())
|
Utc.ymd(date.year(), date.month(), date.day())
|
||||||
.and_hms(start.0, start.1, 0),
|
.and_hms(start.0, start.1, 0),
|
||||||
);
|
);
|
||||||
course.dtend = Some(
|
course.dtend = Some(
|
||||||
Utc.ymd(date.year(), date.month(), date.day())
|
Utc.ymd(date.year(), date.month(), date.day())
|
||||||
.and_hms(end.0, end.1, 0),
|
.and_hms(end.0, end.1, 0),
|
||||||
);
|
);
|
||||||
|
|
||||||
semester.push(course);
|
semester.push(course);
|
||||||
|
}
|
||||||
|
date += Duration::days(1);
|
||||||
}
|
}
|
||||||
date += Duration::days(1);
|
// From friday to monday
|
||||||
|
date += Duration::days(2);
|
||||||
}
|
}
|
||||||
// From friday to monday
|
let after_break = break_data.get(1).unwrap();
|
||||||
date += Duration::days(2);
|
date = after_break.0;
|
||||||
|
rep = after_break.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
semester
|
semester
|
||||||
|
|
Reference in a new issue