Skip to content

Instantly share code, notes, and snippets.

View catamphetamine's full-sized avatar
💭
Having enemies means you've stood up for something

Nikolay catamphetamine

💭
Having enemies means you've stood up for something
View GitHub Profile
/**
* Returns the week number for this date.
* https://stackoverflow.com/questions/9045868/javascript-date-getweek
* @param {Date} date
* @param {number} [dowOffset] — The day of week the week "starts" on for your locale - it can be from `0` to `6`. By default `dowOffset` is `0` (USA, Sunday). If `dowOffset` is 1 (Monday), the week returned is the ISO 8601 week number.
* @return {number}
*/
export default function getWeek(date, dowOffset = 0) {
/*getWeek() was developed by Nick Baicoianu at MeanFreePath: http://www.meanfreepath.com */
const newYear = new Date(date.getFullYear(), 0, 1);