Created
June 25, 2019 16:11
-
-
Save lac5/04169495c5d48d0f720f3edaf4662a88 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
let date = new Date(); | |
if (date.getHours() < 5) { | |
date.setDate(date.getDate() - 1); | |
} | |
let thisThu = new Date(date.valueOf() + ((7 - date.getDay()) % 7 - 3) * 86400000); | |
let firstDay = new Date(thisThu.getFullYear(), 0, 1); | |
let year = thisThu.getFullYear(); | |
let week = Math.ceil((thisThu.valueOf() - firstDay.valueOf() + 86400000) / 604800000); | |
let dow = date.getDay() || 7; | |
console.log(('00' + year).slice(-2) + ('00' + week).slice(-2) + dow); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment