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

Function weekParser

test/angular/1.5/angular.js:24543–24573  ·  view source on GitHub ↗
(isoWeek, existingDate)

Source from the content-addressed store, hash-verified

24541}
24542
24543function weekParser(isoWeek, existingDate) {
24544 if (isDate(isoWeek)) {
24545 return isoWeek;
24546 }
24547
24548 if (isString(isoWeek)) {
24549 WEEK_REGEXP.lastIndex = 0;
24550 var parts = WEEK_REGEXP.exec(isoWeek);
24551 if (parts) {
24552 var year = +parts[1],
24553 week = +parts[2],
24554 hours = 0,
24555 minutes = 0,
24556 seconds = 0,
24557 milliseconds = 0,
24558 firstThurs = getFirstThursdayOfYear(year),
24559 addDays = (week - 1) * 7;
24560
24561 if (existingDate) {
24562 hours = existingDate.getHours();
24563 minutes = existingDate.getMinutes();
24564 seconds = existingDate.getSeconds();
24565 milliseconds = existingDate.getMilliseconds();
24566 }
24567
24568 return new Date(year, 0, firstThurs.getDate() + addDays, hours, minutes, seconds, milliseconds);
24569 }
24570 }
24571
24572 return NaN;
24573}
24574
24575function createDateParser(regexp, mapping) {
24576 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