Add next date calculation
This commit is contained in:
parent
184dd1eadb
commit
160c14de2e
|
@ -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>
|
||||
|
|
Reference in New Issue