MCPcopy Create free account
hub / github.com/cafebazaar/blacksmith / weekParser

Function weekParser

web/static/bower_components/angular/angular.js:21730–21760  ·  view source on GitHub ↗
(isoWeek, existingDate)

Source from the content-addressed store, hash-verified

21728}
21729
21730function weekParser(isoWeek, existingDate) {
21731 if (isDate(isoWeek)) {
21732 return isoWeek;
21733 }
21734
21735 if (isString(isoWeek)) {
21736 WEEK_REGEXP.lastIndex = 0;
21737 var parts = WEEK_REGEXP.exec(isoWeek);
21738 if (parts) {
21739 var year = +parts[1],
21740 week = +parts[2],
21741 hours = 0,
21742 minutes = 0,
21743 seconds = 0,
21744 milliseconds = 0,
21745 firstThurs = getFirstThursdayOfYear(year),
21746 addDays = (week - 1) * 7;
21747
21748 if (existingDate) {
21749 hours = existingDate.getHours();
21750 minutes = existingDate.getMinutes();
21751 seconds = existingDate.getSeconds();
21752 milliseconds = existingDate.getMilliseconds();
21753 }
21754
21755 return new Date(year, 0, firstThurs.getDate() + addDays, hours, minutes, seconds, milliseconds);
21756 }
21757 }
21758
21759 return NaN;
21760}
21761
21762function createDateParser(regexp, mapping) {
21763 return function(iso, date) {

Callers

nothing calls this directly

Calls 3

isDateFunction · 0.85
isStringFunction · 0.85
getFirstThursdayOfYearFunction · 0.85

Tested by

no test coverage detected