MCPcopy Create free account
hub / github.com/EricSimons/ionic-course / weekParser

Function weekParser

code/songhop/www/lib/angular/angular.js:19633–19663  ·  view source on GitHub ↗
(isoWeek, existingDate)

Source from the content-addressed store, hash-verified

19631}
19632
19633function weekParser(isoWeek, existingDate) {
19634 if (isDate(isoWeek)) {
19635 return isoWeek;
19636 }
19637
19638 if (isString(isoWeek)) {
19639 WEEK_REGEXP.lastIndex = 0;
19640 var parts = WEEK_REGEXP.exec(isoWeek);
19641 if (parts) {
19642 var year = +parts[1],
19643 week = +parts[2],
19644 hours = 0,
19645 minutes = 0,
19646 seconds = 0,
19647 milliseconds = 0,
19648 firstThurs = getFirstThursdayOfYear(year),
19649 addDays = (week - 1) * 7;
19650
19651 if (existingDate) {
19652 hours = existingDate.getHours();
19653 minutes = existingDate.getMinutes();
19654 seconds = existingDate.getSeconds();
19655 milliseconds = existingDate.getMilliseconds();
19656 }
19657
19658 return new Date(year, 0, firstThurs.getDate() + addDays, hours, minutes, seconds, milliseconds);
19659 }
19660 }
19661
19662 return NaN;
19663}
19664
19665function createDateParser(regexp, mapping) {
19666 return function(iso, date) {

Callers

nothing calls this directly

Calls 4

execMethod · 0.80
isDateFunction · 0.70
isStringFunction · 0.70
getFirstThursdayOfYearFunction · 0.70

Tested by

no test coverage detected