Skip to content

Instantly share code, notes, and snippets.

@alexb5dh
Created January 25, 2018 17:20
Show Gist options
  • Save alexb5dh/d0cb98437f496e6b6e35da0067c6bfbe to your computer and use it in GitHub Desktop.
Save alexb5dh/d0cb98437f496e6b6e35da0067c6bfbe to your computer and use it in GitHub Desktop.
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