aboutsummaryrefslogtreecommitdiff
path: root/public/javascripts/weekSelector.js
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2016-12-15 12:46:44 +0100
committerNoah Loomans <noahloomans@gmail.com>2016-12-15 12:46:44 +0100
commit13ceee415eb81a4d72f63df013eca2a442865d81 (patch)
tree72d7a611d034254cb2b9ed6d5dac1180d3a449f7 /public/javascripts/weekSelector.js
parentb2d6055bc83cb88fcce1df5bbc88dd20ca6cdc85 (diff)
use next week if sunday
Diffstat (limited to 'public/javascripts/weekSelector.js')
-rw-r--r--public/javascripts/weekSelector.js38
1 files changed, 27 insertions, 11 deletions
diff --git a/public/javascripts/weekSelector.js b/public/javascripts/weekSelector.js
index 1cf5b56..f0b00ad 100644
--- a/public/javascripts/weekSelector.js
+++ b/public/javascripts/weekSelector.js
@@ -27,7 +27,8 @@ self.getCurrentWeek = function (target) {
self.getSelectedWeek = function () {
const now = new Date()
- const targetDate = new Date(now.getTime() + self._weekOffset * 604800 * 1000)
+ const targetDate = new Date(now.getTime() +
+ self._weekOffset * 604800 * 1000 + 86400 * 1000)
return self.getCurrentWeek(targetDate)
}
@@ -44,17 +45,32 @@ self.updateCurrentWeek = function () {
self.updateDom = function () {
const selectedWeekNumber = self.getSelectedWeek()
+ const isSunday = new Date().getDay() === 0
let humanReadableWeek = null
- switch (self._weekOffset) {
- case 0:
- humanReadableWeek = 'Huidige week'
- break
- case 1:
- humanReadableWeek = 'Volgende week'
- break
- case -1:
- humanReadableWeek = 'Vorige week'
- break
+ if (isSunday) {
+ switch (self._weekOffset) {
+ case 0:
+ humanReadableWeek = 'Aanstaande week'
+ break
+ case 1:
+ humanReadableWeek = 'Volgende week'
+ break
+ case -1:
+ humanReadableWeek = 'Afgelopen week'
+ break
+ }
+ } else {
+ switch (self._weekOffset) {
+ case 0:
+ humanReadableWeek = 'Huidige week'
+ break
+ case 1:
+ humanReadableWeek = 'Volgende week'
+ break
+ case -1:
+ humanReadableWeek = 'Vorige week'
+ break
+ }
}
if (humanReadableWeek != null) {
self._nodes.currentWeekText.textContent = `${humanReadableWeek} • ${selectedWeekNumber}`