Created
January 25, 2018 17:20
-
-
Save alexb5dh/d0cb98437f496e6b6e35da0067c6bfbe 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
function areSameWeek(date1, date2){ | |
if (date1.getDate() === date2.getDate()) | |
return true; | |
if (Math.abs(date1.getDate() - date2.getDate()) >= 7) | |
return false; | |
return (date1.getDay() > date2.getDay() && date1.getTime() > date2.getTime()) || | |
(date1.getDay() < date2.getDay() && date1.getTime() < date2.getTime()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment