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

Function weekParser

lib/test/angular/1.4.3/angular.js:21508–21538  ·  view source on GitHub ↗
(isoWeek, existingDate)

Source from the content-addressed store, hash-verified

21506}
21507
21508function weekParser(isoWeek, existingDate) {
21509 if (isDate(isoWeek)) {
21510 return isoWeek;
21511 }
21512
21513 if (isString(isoWeek)) {
21514 WEEK_REGEXP.lastIndex = 0;
21515 var parts = WEEK_REGEXP.exec(isoWeek);
21516 if (parts) {
21517 var year = +parts[1],
21518 week = +parts[2],
21519 hours = 0,
21520 minutes = 0,
21521 seconds = 0,
21522 milliseconds = 0,
21523 firstThurs = getFirstThursdayOfYear(year),
21524 addDays = (week - 1) * 7;
21525
21526 if (existingDate) {
21527 hours = existingDate.getHours();
21528 minutes = existingDate.getMinutes();
21529 seconds = existingDate.getSeconds();
21530 milliseconds = existingDate.getMilliseconds();
21531 }
21532
21533 return new Date(year, 0, firstThurs.getDate() + addDays, hours, minutes, seconds, milliseconds);
21534 }
21535 }
21536
21537 return NaN;
21538}
21539
21540function createDateParser(regexp, mapping) {
21541 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