diff options
author | Noah Loomans <noahloomans@gmail.com> | 2017-01-08 11:48:13 +0100 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2017-01-08 11:48:13 +0100 |
commit | 320c18af3ee9cbeaaae3d4796dd7f15a5ac90889 (patch) | |
tree | d63339d425a2a6a20c883d896b9ed492272d6085 /public/javascripts/getWeek.js | |
parent | 4e8da42863406764a659a7337e774ad216d356c9 (diff) | |
parent | dea89e1ec600b302a8db33dd48080b901aee7c7e (diff) |
Merge branch 'master' of github.com:nloomans/rooster-mml
Diffstat (limited to 'public/javascripts/getWeek.js')
-rw-r--r-- | public/javascripts/getWeek.js | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/public/javascripts/getWeek.js b/public/javascripts/getWeek.js deleted file mode 100644 index 40b0bb4..0000000 --- a/public/javascripts/getWeek.js +++ /dev/null @@ -1,33 +0,0 @@ -// copied from http://www.meetingpointmco.nl/Roosters-AL/doc/dagroosters/untisscripts.js, -// were using the same code as they do to be sure that we always get the same -// week number. -function getWeek () { - // Create a copy of this date object - const target = new Date() - - // ISO week date weeks start on monday - // so correct the day number - const dayNr = (target.getDay() + 6) % 7 - - // ISO 8601 states that week 1 is the week - // with the first thursday of that year. - // Set the target date to the thursday in the target week - target.setDate(target.getDate() - dayNr + 3) - - // Store the millisecond value of the target date - const firstThursday = target.valueOf() - - // Set the target to the first thursday of the year - // First set the target to january first - target.setMonth(0, 1) - // Not a thursday? Correct the date to the next thursday - if (target.getDay() !== 4) { - target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7) - } - - // The weeknumber is the number of weeks between the - // first thursday of the year and the thursday in the target week - return 1 + Math.ceil((firstThursday - target) / 604800000) // 604800000 = 7 * 24 * 3600 * 1000 -} - -module.exports = getWeek |