Created
July 4, 2019 14:04
-
-
Save one-more/256e16694a4e7f897799a016476c4f1f 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
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