#11: Adding method to calculate semester
All checks were successful
Jenkins Production Deployment

This commit is contained in:
Patrick Müller 2021-10-13 16:10:12 +02:00
parent 4f70e5a943
commit 0e9a1a8018

View File

@ -83,6 +83,29 @@ let courseLinks = {
'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 */
const toggleDarkMode = () => {