Skip to content

Instantly share code, notes, and snippets.

@one-more
Created July 4, 2019 14:04
Show Gist options
  • Save one-more/256e16694a4e7f897799a016476c4f1f to your computer and use it in GitHub Desktop.
Save one-more/256e16694a4e7f897799a016476c4f1f to your computer and use it in GitHub Desktop.
function createDateForDayNum(dayNum: number) {
const date = new Date();
const day = date.getDay();
const diff = date.getDate() - day + (day == 0 ? -6 : dayNum);
return new Date(date.setDate(diff));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment