MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / firstWeekOffset

Function firstWeekOffset

tests/test_code/js/moment/moment.js:1312–1319  ·  view source on GitHub ↗
(year, dow, doy)

Source from the content-addressed store, hash-verified

1310
1311 // start-of-first-week - start-of-year
1312 function firstWeekOffset(year, dow, doy) {
1313 var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
1314 fwd = 7 + dow - doy,
1315 // first-week day local weekday -- which local weekday is fwd
1316 fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
1317
1318 return -fwdlw + fwd - 1;
1319 }
1320
1321 // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
1322 function dayOfYearFromWeeks(year, week, weekday, dow, doy) {

Callers 3

dayOfYearFromWeeksFunction · 0.85
weekOfYearFunction · 0.85
weeksInYearFunction · 0.85

Calls 1

createUTCDateFunction · 0.85

Tested by

no test coverage detected