Skip to content

Instantly share code, notes, and snippets.

@uno-de-piera
Created May 26, 2018 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uno-de-piera/99fa8dbe55aa74f558ea907b220bee05 to your computer and use it in GitHub Desktop.
Save uno-de-piera/99fa8dbe55aa74f558ea907b220bee05 to your computer and use it in GitHub Desktop.
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