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

Function computeWeekdaysParse

tests/test_code/js/moment/moment.js:1809–1859  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1807 }
1808
1809 function computeWeekdaysParse() {
1810 function cmpLenRev(a, b) {
1811 return b.length - a.length;
1812 }
1813
1814 var minPieces = [],
1815 shortPieces = [],
1816 longPieces = [],
1817 mixedPieces = [],
1818 i,
1819 mom,
1820 minp,
1821 shortp,
1822 longp;
1823 for (i = 0; i < 7; i++) {
1824 // make the regex if we don't have it already
1825 mom = createUTC([2000, 1]).day(i);
1826 minp = regexEscape(this.weekdaysMin(mom, ''));
1827 shortp = regexEscape(this.weekdaysShort(mom, ''));
1828 longp = regexEscape(this.weekdays(mom, ''));
1829 minPieces.push(minp);
1830 shortPieces.push(shortp);
1831 longPieces.push(longp);
1832 mixedPieces.push(minp);
1833 mixedPieces.push(shortp);
1834 mixedPieces.push(longp);
1835 }
1836 // Sorting makes sure if one weekday (or abbr) is a prefix of another it
1837 // will match the longer piece.
1838 minPieces.sort(cmpLenRev);
1839 shortPieces.sort(cmpLenRev);
1840 longPieces.sort(cmpLenRev);
1841 mixedPieces.sort(cmpLenRev);
1842
1843 this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
1844 this._weekdaysShortRegex = this._weekdaysRegex;
1845 this._weekdaysMinRegex = this._weekdaysRegex;
1846
1847 this._weekdaysStrictRegex = new RegExp(
1848 '^(' + longPieces.join('|') + ')',
1849 'i'
1850 );
1851 this._weekdaysShortStrictRegex = new RegExp(
1852 '^(' + shortPieces.join('|') + ')',
1853 'i'
1854 );
1855 this._weekdaysMinStrictRegex = new RegExp(
1856 '^(' + minPieces.join('|') + ')',
1857 'i'
1858 );
1859 }
1860
1861 // FORMATTING
1862

Callers

nothing calls this directly

Calls 2

createUTCFunction · 0.85
regexEscapeFunction · 0.85

Tested by

no test coverage detected