forked from Anri/cal8tor
print it lines by line, without table
This commit is contained in:
parent
96c5033150
commit
0d8e802db7
2 changed files with 34 additions and 3 deletions
|
@ -6,7 +6,7 @@ use scraper::Selector;
|
|||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
use crate::utils::{
|
||||
get_hours, get_semester, get_webpage, get_year,
|
||||
format_time_slot, get_hours, get_semester, get_webpage, get_year,
|
||||
models::{Info, InfoList},
|
||||
Capitalize,
|
||||
};
|
||||
|
@ -271,6 +271,28 @@ fn add_courses(
|
|||
}
|
||||
|
||||
/// Display the timetable
|
||||
pub fn display(timetable: &(Arc<[String]>, (usize, Vec<models::Day>))) {
|
||||
todo!("{:#?}", timetable)
|
||||
pub fn display(timetable: &(Arc<[String]>, (usize, Vec<Day>))) {
|
||||
for day in &timetable.1 .1 {
|
||||
for (index, course_option) in day.courses.iter().enumerate() {
|
||||
if let Some(course) = course_option {
|
||||
if index == 0 {
|
||||
println!("\n{}:", day.name);
|
||||
}
|
||||
|
||||
println!(
|
||||
" {} - {} : {} ({}) // {}",
|
||||
format_time_slot(course.start, course.size),
|
||||
course
|
||||
.category
|
||||
.iter()
|
||||
.map(std::string::ToString::to_string)
|
||||
.collect::<Vec<String>>()
|
||||
.join(", "),
|
||||
course.name,
|
||||
course.room,
|
||||
course.professor.as_deref().unwrap_or("N/A"),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,3 +161,12 @@ pub fn get_count<'a>(
|
|||
|
||||
(courses, counts)
|
||||
}
|
||||
|
||||
pub fn format_time_slot(start: usize, size: usize) -> String {
|
||||
let start_hour = 8 + (start * 15) / 60;
|
||||
let start_minute = (start * 15) % 60;
|
||||
let end_hour = start_hour + (size * 15) / 60;
|
||||
let end_minute = (start_minute + (size * 15)) % 60;
|
||||
|
||||
format!("{start_hour:02}h{start_minute:02}-{end_hour:02}h{end_minute:02}")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue