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

Function weekParser

lib/test/angular/1.5.0/angular.js:22731–22761  ·  view source on GitHub ↗
(isoWeek, existingDate)

Source from the content-addressed store, hash-verified

22729}
22730
22731function weekParser(isoWeek, existingDate) {
22732 if (isDate(isoWeek)) {
22733 return isoWeek;
22734 }
22735
22736 if (isString(isoWeek)) {
22737 WEEK_REGEXP.lastIndex = 0;
22738 var parts = WEEK_REGEXP.exec(isoWeek);
22739 if (parts) {
22740 var year = +parts[1],
22741 week = +parts[2],
22742 hours = 0,
22743 minutes = 0,
22744 seconds = 0,
22745 milliseconds = 0,
22746 firstThurs = getFirstThursdayOfYear(year),
22747 addDays = (week - 1) * 7;
22748
22749 if (existingDate) {
22750 hours = existingDate.getHours();
22751 minutes = existingDate.getMinutes();
22752 seconds = existingDate.getSeconds();
22753 milliseconds = existingDate.getMilliseconds();
22754 }
22755
22756 return new Date(year, 0, firstThurs.getDate() + addDays, hours, minutes, seconds, milliseconds);
22757 }
22758 }
22759
22760 return NaN;
22761}
22762
22763function createDateParser(regexp, mapping) {
22764 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