diff options
author | Noah Loomans <noahloomans@gmail.com> | 2016-09-06 15:10:44 +0200 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2016-09-06 15:10:44 +0200 |
commit | 571e3dea5e85c4ba54065acd8e6feb5fe1f9ec03 (patch) | |
tree | 23d335c4f374e58c04bdb80ed0a4881267598884 /public/javascripts/getURLOfUser.js | |
parent | ee9246af8e093ba79c126385809e76a52b40ccc0 (diff) |
added week selection
Diffstat (limited to 'public/javascripts/getURLOfUser.js')
-rw-r--r-- | public/javascripts/getURLOfUser.js | 33 |
1 files changed, 1 insertions, 32 deletions
diff --git a/public/javascripts/getURLOfUser.js b/public/javascripts/getURLOfUser.js index 294d7c4..a546ace 100644 --- a/public/javascripts/getURLOfUser.js +++ b/public/javascripts/getURLOfUser.js @@ -1,36 +1,5 @@ const leftPad = require('left-pad') - -// 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 - var target = new Date() - - // ISO week date weeks start on monday - // so correct the day number - var 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 - var 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 -} +const getWeek = require('./getWeek') function getURLOfUsers (weekOffset, type, id) { return `http://${window.location.host}/meetingpointProxy/Roosters-AL%2Fdoc%2Fdagroosters%2F` + |