-
-
Save uno-de-piera/99fa8dbe55aa74f558ea907b220bee05 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const moment = require('moment'); | |
const state = { | |
start_date: moment(new Date()).local().format('YYYY-MM-DDTHH:mm'), | |
end_date: moment().add(30, 'days').local().format('YYYY-MM-DDTHH:mm'), | |
}; | |
const mutations = { | |
SET_START_DATE: (state, value) => { | |
state.start_date = value; | |
}, | |
SET_END_DATE: (state, value) => { | |
state.end_date = value; | |
}, | |
}; | |
const getters = { | |
differenceDate (state) { | |
const start = moment(state.start_date); | |
const end = moment(state.end_date); | |
return end.diff(start, 'days'); | |
} | |
}; | |
export default { | |
state, | |
mutations, | |
getters | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment