#11: Adding method to calculate semester
All checks were successful
Jenkins Production Deployment
All checks were successful
Jenkins Production Deployment
This commit is contained in:
parent
4f70e5a943
commit
0e9a1a8018
23
scripts.js
23
scripts.js
|
@ -83,6 +83,29 @@ let courseLinks = {
|
||||||
'TINF20B5': {user: 'strand', file: 'TINF20B5'}
|
'TINF20B5': {user: 'strand', file: 'TINF20B5'}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates, in which semester the given course currently is
|
||||||
|
* @param course The course to calculate the semester for
|
||||||
|
* @returns {number} The number of the semester they are in
|
||||||
|
*/
|
||||||
|
function calculateSemester(course) {
|
||||||
|
let yearRegex = new RegExp('[a-zA-Z]*([0-9]{2})B[0-9]');
|
||||||
|
|
||||||
|
let match = yearRegex.exec(course);
|
||||||
|
let startYear = '20';
|
||||||
|
if (match !== null) {
|
||||||
|
startYear += match[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
let currentYear = new Date().getFullYear();
|
||||||
|
|
||||||
|
let yearDifference = currentYear - startYear;
|
||||||
|
|
||||||
|
let semesters = yearDifference * 2 + 1;
|
||||||
|
|
||||||
|
return semesters;
|
||||||
|
}
|
||||||
|
|
||||||
/* Toggle Dark-Mode */
|
/* Toggle Dark-Mode */
|
||||||
|
|
||||||
const toggleDarkMode = () => {
|
const toggleDarkMode = () => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user