MCPcopy
hub / github.com/angular-ui/ui-router / weekParser

Function weekParser

test/angular/1.6/angular.js:25669–25699  ·  view source on GitHub ↗
(isoWeek, existingDate)

Source from the content-addressed store, hash-verified

25667}
25668
25669function weekParser(isoWeek, existingDate) {
25670 if (isDate(isoWeek)) {
25671 return isoWeek;
25672 }
25673
25674 if (isString(isoWeek)) {
25675 WEEK_REGEXP.lastIndex = 0;
25676 var parts = WEEK_REGEXP.exec(isoWeek);
25677 if (parts) {
25678 var year = +parts[1],
25679 week = +parts[2],
25680 hours = 0,
25681 minutes = 0,
25682 seconds = 0,
25683 milliseconds = 0,
25684 firstThurs = getFirstThursdayOfYear(year),
25685 addDays = (week - 1) * 7;
25686
25687 if (existingDate) {
25688 hours = existingDate.getHours();
25689 minutes = existingDate.getMinutes();
25690 seconds = existingDate.getSeconds();
25691 milliseconds = existingDate.getMilliseconds();
25692 }
25693
25694 return new Date(year, 0, firstThurs.getDate() + addDays, hours, minutes, seconds, milliseconds);
25695 }
25696 }
25697
25698 return NaN;
25699}
25700
25701function createDateParser(regexp, mapping) {
25702 return function(iso, date) {

Callers

nothing calls this directly

Calls 3

isDateFunction · 0.70
isStringFunction · 0.70
getFirstThursdayOfYearFunction · 0.70

Tested by

no test coverage detected