Skip to content

Instantly share code, notes, and snippets.

@eduardonunesp
Created April 13, 2016 17:37
Show Gist options
  • Save eduardonunesp/e3df7dcca040b7f4b406d29d5617de3a to your computer and use it in GitHub Desktop.
Save eduardonunesp/e3df7dcca040b7f4b406d29d5617de3a to your computer and use it in GitHub Desktop.
const moment = require('moment');
function dayDiff(d1, d2) {
return Math.abs(moment(d2).diff(d1, 'days'));
}
const dateLen = {
'day' : 1,
'week' : 7,
'month': 31,
'year' : 365
};
const checks = [
dayDiff(moment(), moment().add(1, 'days')) >= dateLen.day;
dayDiff(moment(), moment().add(1, 'days')) >= dateLen.week;
];
checks.map(res => res); // [true, false]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment