forked from Anri/cal8tor
add post-break weeks
This commit is contained in:
parent
1fea0a4e40
commit
8cb99e69af
2 changed files with 27 additions and 20 deletions
|
@ -205,8 +205,8 @@ type T = (
|
|||
type D = std::collections::HashMap<
|
||||
// Semester
|
||||
usize,
|
||||
// List of start and end times of course weeks
|
||||
Vec<(chrono::DateTime<Utc>, chrono::DateTime<Utc>)>,
|
||||
// List of start and repetition of course weeks
|
||||
Vec<(chrono::DateTime<Utc>, i64)>,
|
||||
>;
|
||||
|
||||
/// Build the timetable
|
||||
|
@ -242,11 +242,15 @@ pub fn build(timetable: T, dates: D) -> Vec<models::Course> {
|
|||
let mut semester = Vec::new();
|
||||
|
||||
// Start date of the back-to-school week
|
||||
let mut date = dates.get(&timetable.1 .0).unwrap().get(0).unwrap().0;
|
||||
for day in timetable.1 .1 {
|
||||
for mut course in day.courses.into_iter().flatten() {
|
||||
let data = dates.get(&timetable.1 .0).unwrap().get(0).unwrap();
|
||||
let mut date = data.0;
|
||||
// For each weeks
|
||||
for _ in 0..(data.1) {
|
||||
for day in &timetable.1 .1 {
|
||||
for mut course in day.courses.clone().into_iter().flatten() {
|
||||
// Get the hours
|
||||
let start = schedules.get(course.start).unwrap().0;
|
||||
// -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
|
||||
|
@ -263,6 +267,9 @@ pub fn build(timetable: T, dates: D) -> Vec<models::Course> {
|
|||
}
|
||||
date += Duration::days(1);
|
||||
}
|
||||
// From friday to monday
|
||||
date += Duration::days(2);
|
||||
}
|
||||
|
||||
semester
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Course {
|
||||
/// Course's name
|
||||
pub name: String,
|
||||
|
|
Reference in a new issue