MCPcopy Index your code
hub / github.com/angular-ui/ui-router / weekParser

Function weekParser

test/angular/1.7/angular.js:26587–26617  ·  view source on GitHub ↗
(isoWeek, existingDate)

Source from the content-addressed store, hash-verified

26585}
26586
26587function weekParser(isoWeek, existingDate) {
26588 if (isDate(isoWeek)) {
26589 return isoWeek;
26590 }
26591
26592 if (isString(isoWeek)) {
26593 WEEK_REGEXP.lastIndex = 0;
26594 var parts = WEEK_REGEXP.exec(isoWeek);
26595 if (parts) {
26596 var year = +parts[1],
26597 week = +parts[2],
26598 hours = 0,
26599 minutes = 0,
26600 seconds = 0,
26601 milliseconds = 0,
26602 firstThurs = getFirstThursdayOfYear(year),
26603 addDays = (week - 1) * 7;
26604
26605 if (existingDate) {
26606 hours = existingDate.getHours();
26607 minutes = existingDate.getMinutes();
26608 seconds = existingDate.getSeconds();
26609 milliseconds = existingDate.getMilliseconds();
26610 }
26611
26612 return new Date(year, 0, firstThurs.getDate() + addDays, hours, minutes, seconds, milliseconds);
26613 }
26614 }
26615
26616 return NaN;
26617}
26618
26619function createDateParser(regexp, mapping) {
26620 return function(iso, previousDate) {

Callers

nothing calls this directly

Calls 3

isDateFunction · 0.70
isStringFunction · 0.70
getFirstThursdayOfYearFunction · 0.70

Tested by

no test coverage detected