include the after-break

This commit is contained in:
Mylloon 2022-08-16 14:50:22 +02:00
parent 8cb99e69af
commit 732f56f0be
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -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