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

Function weekParser

lib/test/angular/1.8.0/angular.js:26652–26682  ·  view source on GitHub ↗
(isoWeek, existingDate)

Source from the content-addressed store, hash-verified

26650}
26651
26652function weekParser(isoWeek, existingDate) {
26653 if (isDate(isoWeek)) {
26654 return isoWeek;
26655 }
26656
26657 if (isString(isoWeek)) {
26658 WEEK_REGEXP.lastIndex = 0;
26659 var parts = WEEK_REGEXP.exec(isoWeek);
26660 if (parts) {
26661 var year = +parts[1],
26662 week = +parts[2],
26663 hours = 0,
26664 minutes = 0,
26665 seconds = 0,
26666 milliseconds = 0,
26667 firstThurs = getFirstThursdayOfYear(year),
26668 addDays = (week - 1) * 7;
26669
26670 if (existingDate) {
26671 hours = existingDate.getHours();
26672 minutes = existingDate.getMinutes();
26673 seconds = existingDate.getSeconds();
26674 milliseconds = existingDate.getMilliseconds();
26675 }
26676
26677 return new Date(year, 0, firstThurs.getDate() + addDays, hours, minutes, seconds, milliseconds);
26678 }
26679 }
26680
26681 return NaN;
26682}
26683
26684function createDateParser(regexp, mapping) {
26685 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