Add next date calculation

This commit is contained in:
kolaente 2020-11-22 22:08:39 +01:00
parent 184dd1eadb
commit 160c14de2e
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 25 additions and 0 deletions

View File

@ -150,6 +150,31 @@ export default {
setDate(date) {
console.log(date)
},
getDayIntervalFromString(date) {
const currentDay = (new Date()).getDay()
switch(date) {
case 'today':
return 0
case 'tomorrow':
return 1
case 'nextMonday':
// Monday is 1, so we calculate the distance to the next 1
return (7 + currentDay - 1) % 7
case 'thisWeekend':
// Saturday is 6 so we calculate the distance to the next 6
return (7 + currentDay - 6) % 7
case 'laterThisWeek':
return 2
case 'laterNextWeek':
return 0
case 'nextWeek':
return 7
default:
return 0;
}
},
},
}
</script>