handle a week

This commit is contained in:
Mylloon 2022-08-16 14:05:25 +02:00
parent e37d6b04cc
commit bb09adfe22
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -1,4 +1,4 @@
use chrono::{TimeZone, Utc}; use chrono::{Datelike, Duration, TimeZone, Utc};
use regex::Regex; use regex::Regex;
use scraper::{Html, Selector}; use scraper::{Html, Selector};
@ -238,20 +238,31 @@ pub fn build(timetable: T, dates: D) -> Vec<models::Course> {
schedules.push(((h1, m1), (h2, m2))); schedules.push(((h1, m1), (h2, m2)));
} }
let semester = (timetable.1).0; // Store all the courses for the semester
let requested_timetable = (timetable.1).1; let mut semester = Vec::new();
let _requested_dates = dates.get(&semester).unwrap(); // 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() {
// Get the hours
let start = schedules.get(course.start).unwrap().0;
let end = schedules.get(course.start + course.size - 1).unwrap().1;
println!("{:#?}", requested_timetable); // Add the changed datetimes
course.dtstart = Some(
Utc.ymd(date.year(), date.month(), date.day())
.and_hms(start.0, start.1, 0),
);
course.dtend = Some(
Utc.ymd(date.year(), date.month(), date.day())
.and_hms(end.0, end.1, 0),
);
vec![models::Course { semester.push(course);
name: String::from("Cours"), }
professor: None, date += Duration::days(1);
room: String::from("A188"), }
start: 0,
size: 0, semester
dtstart: Some(Utc.ymd(2022, 9, 19).and_hms(13, 30, 0)),
dtend: Some(Utc.ymd(2022, 9, 19).and_hms(16, 30, 0)),
}]
} }