MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / localeWeekdaysParse

Function localeWeekdaysParse

tests/test_code/js/moment/moment.js:1642–1707  ·  view source on GitHub ↗
(weekdayName, format, strict)

Source from the content-addressed store, hash-verified

1640 }
1641
1642 function localeWeekdaysParse(weekdayName, format, strict) {
1643 var i, mom, regex;
1644
1645 if (this._weekdaysParseExact) {
1646 return handleStrictParse$1.call(this, weekdayName, format, strict);
1647 }
1648
1649 if (!this._weekdaysParse) {
1650 this._weekdaysParse = [];
1651 this._minWeekdaysParse = [];
1652 this._shortWeekdaysParse = [];
1653 this._fullWeekdaysParse = [];
1654 }
1655
1656 for (i = 0; i < 7; i++) {
1657 // make the regex if we don't have it already
1658
1659 mom = createUTC([2000, 1]).day(i);
1660 if (strict && !this._fullWeekdaysParse[i]) {
1661 this._fullWeekdaysParse[i] = new RegExp(
1662 '^' + this.weekdays(mom, '').replace('.', '\\.?') + '$',
1663 'i'
1664 );
1665 this._shortWeekdaysParse[i] = new RegExp(
1666 '^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$',
1667 'i'
1668 );
1669 this._minWeekdaysParse[i] = new RegExp(
1670 '^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$',
1671 'i'
1672 );
1673 }
1674 if (!this._weekdaysParse[i]) {
1675 regex =
1676 '^' +
1677 this.weekdays(mom, '') +
1678 '|^' +
1679 this.weekdaysShort(mom, '') +
1680 '|^' +
1681 this.weekdaysMin(mom, '');
1682 this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
1683 }
1684 // test the regex
1685 if (
1686 strict &&
1687 format === 'dddd' &&
1688 this._fullWeekdaysParse[i].test(weekdayName)
1689 ) {
1690 return i;
1691 } else if (
1692 strict &&
1693 format === 'ddd' &&
1694 this._shortWeekdaysParse[i].test(weekdayName)
1695 ) {
1696 return i;
1697 } else if (
1698 strict &&
1699 format === 'dd' &&

Callers

nothing calls this directly

Calls 2

createUTCFunction · 0.85
testMethod · 0.80

Tested by

no test coverage detected