MCPcopy Create free account
hub / github.com/angular-ui/ui-router / weekParser

Function weekParser

test/angular/1.3/angular.js:19969–19999  ·  view source on GitHub ↗
(isoWeek, existingDate)

Source from the content-addressed store, hash-verified

19967}
19968
19969function weekParser(isoWeek, existingDate) {
19970 if (isDate(isoWeek)) {
19971 return isoWeek;
19972 }
19973
19974 if (isString(isoWeek)) {
19975 WEEK_REGEXP.lastIndex = 0;
19976 var parts = WEEK_REGEXP.exec(isoWeek);
19977 if (parts) {
19978 var year = +parts[1],
19979 week = +parts[2],
19980 hours = 0,
19981 minutes = 0,
19982 seconds = 0,
19983 milliseconds = 0,
19984 firstThurs = getFirstThursdayOfYear(year),
19985 addDays = (week - 1) * 7;
19986
19987 if (existingDate) {
19988 hours = existingDate.getHours();
19989 minutes = existingDate.getMinutes();
19990 seconds = existingDate.getSeconds();
19991 milliseconds = existingDate.getMilliseconds();
19992 }
19993
19994 return new Date(year, 0, firstThurs.getDate() + addDays, hours, minutes, seconds, milliseconds);
19995 }
19996 }
19997
19998 return NaN;
19999}
20000
20001function createDateParser(regexp, mapping) {
20002 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