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

Function weekParser

lib/test/angular/1.6.7/angular.js:25305–25335  ·  view source on GitHub ↗
(isoWeek, existingDate)

Source from the content-addressed store, hash-verified

25303}
25304
25305function weekParser(isoWeek, existingDate) {
25306 if (isDate(isoWeek)) {
25307 return isoWeek;
25308 }
25309
25310 if (isString(isoWeek)) {
25311 WEEK_REGEXP.lastIndex = 0;
25312 var parts = WEEK_REGEXP.exec(isoWeek);
25313 if (parts) {
25314 var year = +parts[1],
25315 week = +parts[2],
25316 hours = 0,
25317 minutes = 0,
25318 seconds = 0,
25319 milliseconds = 0,
25320 firstThurs = getFirstThursdayOfYear(year),
25321 addDays = (week - 1) * 7;
25322
25323 if (existingDate) {
25324 hours = existingDate.getHours();
25325 minutes = existingDate.getMinutes();
25326 seconds = existingDate.getSeconds();
25327 milliseconds = existingDate.getMilliseconds();
25328 }
25329
25330 return new Date(year, 0, firstThurs.getDate() + addDays, hours, minutes, seconds, milliseconds);
25331 }
25332 }
25333
25334 return NaN;
25335}
25336
25337function createDateParser(regexp, mapping) {
25338 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