MCPcopy
hub / github.com/angular-ui/ui-router / weekParser

Function weekParser

test/angular/1.4/angular.js:22279–22309  ·  view source on GitHub ↗
(isoWeek, existingDate)

Source from the content-addressed store, hash-verified

22277}
22278
22279function weekParser(isoWeek, existingDate) {
22280 if (isDate(isoWeek)) {
22281 return isoWeek;
22282 }
22283
22284 if (isString(isoWeek)) {
22285 WEEK_REGEXP.lastIndex = 0;
22286 var parts = WEEK_REGEXP.exec(isoWeek);
22287 if (parts) {
22288 var year = +parts[1],
22289 week = +parts[2],
22290 hours = 0,
22291 minutes = 0,
22292 seconds = 0,
22293 milliseconds = 0,
22294 firstThurs = getFirstThursdayOfYear(year),
22295 addDays = (week - 1) * 7;
22296
22297 if (existingDate) {
22298 hours = existingDate.getHours();
22299 minutes = existingDate.getMinutes();
22300 seconds = existingDate.getSeconds();
22301 milliseconds = existingDate.getMilliseconds();
22302 }
22303
22304 return new Date(year, 0, firstThurs.getDate() + addDays, hours, minutes, seconds, milliseconds);
22305 }
22306 }
22307
22308 return NaN;
22309}
22310
22311function createDateParser(regexp, mapping) {
22312 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