Last active
March 19, 2023 16:19
-
-
Save itCarl/2f6bebadb5e105672f5c88b60803f59e to your computer and use it in GitHub Desktop.
Ist die Woche ein grader oder ungrader Turnus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Kalenderwoche, in denen schule ist. | |
const schoolWeeks = [ 2, 6, 9, 12, 17, 20, 23, 26 ]; | |
const weekNumber = (d = new Date()) => | |
{ | |
let startDate = new Date(d.getFullYear(), 0, 1); | |
// EDIT: 19.03.2023 | |
let days = Math.floor((d - startDate) / (7 * 24 * 60 * 60 * 1000)); | |
return Math.ceil(days / 7); | |
}; | |
const getCycle = () => | |
{ | |
const wn = schoolWeeks.indexOf(weekNumber()); | |
return wn < 0 | |
? 'Arbeitswoche' | |
: ( wn % 2 | |
? 'odd week (u.T.)' | |
: 'regular week (g.T.)'); | |
}; | |
// Display the calculated result | |
console.log(getCycle()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment