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

Function weekParser

lib/test/angular/1.7.0/angular.js:25812–25842  ·  view source on GitHub ↗
(isoWeek, existingDate)

Source from the content-addressed store, hash-verified

25810}
25811
25812function weekParser(isoWeek, existingDate) {
25813 if (isDate(isoWeek)) {
25814 return isoWeek;
25815 }
25816
25817 if (isString(isoWeek)) {
25818 WEEK_REGEXP.lastIndex = 0;
25819 var parts = WEEK_REGEXP.exec(isoWeek);
25820 if (parts) {
25821 var year = +parts[1],
25822 week = +parts[2],
25823 hours = 0,
25824 minutes = 0,
25825 seconds = 0,
25826 milliseconds = 0,
25827 firstThurs = getFirstThursdayOfYear(year),
25828 addDays = (week - 1) * 7;
25829
25830 if (existingDate) {
25831 hours = existingDate.getHours();
25832 minutes = existingDate.getMinutes();
25833 seconds = existingDate.getSeconds();
25834 milliseconds = existingDate.getMilliseconds();
25835 }
25836
25837 return new Date(year, 0, firstThurs.getDate() + addDays, hours, minutes, seconds, milliseconds);
25838 }
25839 }
25840
25841 return NaN;
25842}
25843
25844function createDateParser(regexp, mapping) {
25845 return function(iso, previousDate) {

Callers

nothing calls this directly

Calls 3

isDateFunction · 0.70
isStringFunction · 0.70
getFirstThursdayOfYearFunction · 0.70

Tested by

no test coverage detected