Created
April 13, 2016 17:37
-
-
Save eduardonunesp/e3df7dcca040b7f4b406d29d5617de3a to your computer and use it in GitHub Desktop.
This file contains hidden or 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'); | |
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