/pack-rat/003_pack_rat/pack-rat/bower_components/moment/src/lib/units/day-of-week.js |
@@ -0,0 +1,364 @@ |
import { addFormatToken } from '../format/format'; |
import { addUnitAlias } from './aliases'; |
import { addUnitPriority } from './priorities'; |
import { addRegexToken, match1to2, matchWord, regexEscape } from '../parse/regex'; |
import { addWeekParseToken } from '../parse/token'; |
import toInt from '../utils/to-int'; |
import isArray from '../utils/is-array'; |
import indexOf from '../utils/index-of'; |
import hasOwnProp from '../utils/has-own-prop'; |
import { createUTC } from '../create/utc'; |
import getParsingFlags from '../create/parsing-flags'; |
|
// FORMATTING |
|
addFormatToken('d', 0, 'do', 'day'); |
|
addFormatToken('dd', 0, 0, function (format) { |
return this.localeData().weekdaysMin(this, format); |
}); |
|
addFormatToken('ddd', 0, 0, function (format) { |
return this.localeData().weekdaysShort(this, format); |
}); |
|
addFormatToken('dddd', 0, 0, function (format) { |
return this.localeData().weekdays(this, format); |
}); |
|
addFormatToken('e', 0, 0, 'weekday'); |
addFormatToken('E', 0, 0, 'isoWeekday'); |
|
// ALIASES |
|
addUnitAlias('day', 'd'); |
addUnitAlias('weekday', 'e'); |
addUnitAlias('isoWeekday', 'E'); |
|
// PRIORITY |
addUnitPriority('day', 11); |
addUnitPriority('weekday', 11); |
addUnitPriority('isoWeekday', 11); |
|
// PARSING |
|
addRegexToken('d', match1to2); |
addRegexToken('e', match1to2); |
addRegexToken('E', match1to2); |
addRegexToken('dd', function (isStrict, locale) { |
return locale.weekdaysMinRegex(isStrict); |
}); |
addRegexToken('ddd', function (isStrict, locale) { |
return locale.weekdaysShortRegex(isStrict); |
}); |
addRegexToken('dddd', function (isStrict, locale) { |
return locale.weekdaysRegex(isStrict); |
}); |
|
addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) { |
var weekday = config._locale.weekdaysParse(input, token, config._strict); |
// if we didn't get a weekday name, mark the date as invalid |
if (weekday != null) { |
week.d = weekday; |
} else { |
getParsingFlags(config).invalidWeekday = input; |
} |
}); |
|
addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) { |
week[token] = toInt(input); |
}); |
|
// HELPERS |
|
function parseWeekday(input, locale) { |
if (typeof input !== 'string') { |
return input; |
} |
|
if (!isNaN(input)) { |
return parseInt(input, 10); |
} |
|
input = locale.weekdaysParse(input); |
if (typeof input === 'number') { |
return input; |
} |
|
return null; |
} |
|
function parseIsoWeekday(input, locale) { |
if (typeof input === 'string') { |
return locale.weekdaysParse(input) % 7 || 7; |
} |
return isNaN(input) ? null : input; |
} |
|
// LOCALES |
|
export var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'); |
export function localeWeekdays (m, format) { |
if (!m) { |
return isArray(this._weekdays) ? this._weekdays : |
this._weekdays['standalone']; |
} |
return isArray(this._weekdays) ? this._weekdays[m.day()] : |
this._weekdays[this._weekdays.isFormat.test(format) ? 'format' : 'standalone'][m.day()]; |
} |
|
export var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'); |
export function localeWeekdaysShort (m) { |
return (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort; |
} |
|
export var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'); |
export function localeWeekdaysMin (m) { |
return (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin; |
} |
|
function handleStrictParse(weekdayName, format, strict) { |
var i, ii, mom, llc = weekdayName.toLocaleLowerCase(); |
if (!this._weekdaysParse) { |
this._weekdaysParse = []; |
this._shortWeekdaysParse = []; |
this._minWeekdaysParse = []; |
|
for (i = 0; i < 7; ++i) { |
mom = createUTC([2000, 1]).day(i); |
this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase(); |
this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase(); |
this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase(); |
} |
} |
|
if (strict) { |
if (format === 'dddd') { |
ii = indexOf.call(this._weekdaysParse, llc); |
return ii !== -1 ? ii : null; |
} else if (format === 'ddd') { |
ii = indexOf.call(this._shortWeekdaysParse, llc); |
return ii !== -1 ? ii : null; |
} else { |
ii = indexOf.call(this._minWeekdaysParse, llc); |
return ii !== -1 ? ii : null; |
} |
} else { |
if (format === 'dddd') { |
ii = indexOf.call(this._weekdaysParse, llc); |
if (ii !== -1) { |
return ii; |
} |
ii = indexOf.call(this._shortWeekdaysParse, llc); |
if (ii !== -1) { |
return ii; |
} |
ii = indexOf.call(this._minWeekdaysParse, llc); |
return ii !== -1 ? ii : null; |
} else if (format === 'ddd') { |
ii = indexOf.call(this._shortWeekdaysParse, llc); |
if (ii !== -1) { |
return ii; |
} |
ii = indexOf.call(this._weekdaysParse, llc); |
if (ii !== -1) { |
return ii; |
} |
ii = indexOf.call(this._minWeekdaysParse, llc); |
return ii !== -1 ? ii : null; |
} else { |
ii = indexOf.call(this._minWeekdaysParse, llc); |
if (ii !== -1) { |
return ii; |
} |
ii = indexOf.call(this._weekdaysParse, llc); |
if (ii !== -1) { |
return ii; |
} |
ii = indexOf.call(this._shortWeekdaysParse, llc); |
return ii !== -1 ? ii : null; |
} |
} |
} |
|
export function localeWeekdaysParse (weekdayName, format, strict) { |
var i, mom, regex; |
|
if (this._weekdaysParseExact) { |
return handleStrictParse.call(this, weekdayName, format, strict); |
} |
|
if (!this._weekdaysParse) { |
this._weekdaysParse = []; |
this._minWeekdaysParse = []; |
this._shortWeekdaysParse = []; |
this._fullWeekdaysParse = []; |
} |
|
for (i = 0; i < 7; i++) { |
// make the regex if we don't have it already |
|
mom = createUTC([2000, 1]).day(i); |
if (strict && !this._fullWeekdaysParse[i]) { |
this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i'); |
this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i'); |
this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\.?') + '$', 'i'); |
} |
if (!this._weekdaysParse[i]) { |
regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, ''); |
this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i'); |
} |
// test the regex |
if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) { |
return i; |
} else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) { |
return i; |
} else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) { |
return i; |
} else if (!strict && this._weekdaysParse[i].test(weekdayName)) { |
return i; |
} |
} |
} |
|
// MOMENTS |
|
export function getSetDayOfWeek (input) { |
if (!this.isValid()) { |
return input != null ? this : NaN; |
} |
var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay(); |
if (input != null) { |
input = parseWeekday(input, this.localeData()); |
return this.add(input - day, 'd'); |
} else { |
return day; |
} |
} |
|
export function getSetLocaleDayOfWeek (input) { |
if (!this.isValid()) { |
return input != null ? this : NaN; |
} |
var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7; |
return input == null ? weekday : this.add(input - weekday, 'd'); |
} |
|
export function getSetISODayOfWeek (input) { |
if (!this.isValid()) { |
return input != null ? this : NaN; |
} |
|
// behaves the same as moment#day except |
// as a getter, returns 7 instead of 0 (1-7 range instead of 0-6) |
// as a setter, sunday should belong to the previous week. |
|
if (input != null) { |
var weekday = parseIsoWeekday(input, this.localeData()); |
return this.day(this.day() % 7 ? weekday : weekday - 7); |
} else { |
return this.day() || 7; |
} |
} |
|
var defaultWeekdaysRegex = matchWord; |
export function weekdaysRegex (isStrict) { |
if (this._weekdaysParseExact) { |
if (!hasOwnProp(this, '_weekdaysRegex')) { |
computeWeekdaysParse.call(this); |
} |
if (isStrict) { |
return this._weekdaysStrictRegex; |
} else { |
return this._weekdaysRegex; |
} |
} else { |
if (!hasOwnProp(this, '_weekdaysRegex')) { |
this._weekdaysRegex = defaultWeekdaysRegex; |
} |
return this._weekdaysStrictRegex && isStrict ? |
this._weekdaysStrictRegex : this._weekdaysRegex; |
} |
} |
|
var defaultWeekdaysShortRegex = matchWord; |
export function weekdaysShortRegex (isStrict) { |
if (this._weekdaysParseExact) { |
if (!hasOwnProp(this, '_weekdaysRegex')) { |
computeWeekdaysParse.call(this); |
} |
if (isStrict) { |
return this._weekdaysShortStrictRegex; |
} else { |
return this._weekdaysShortRegex; |
} |
} else { |
if (!hasOwnProp(this, '_weekdaysShortRegex')) { |
this._weekdaysShortRegex = defaultWeekdaysShortRegex; |
} |
return this._weekdaysShortStrictRegex && isStrict ? |
this._weekdaysShortStrictRegex : this._weekdaysShortRegex; |
} |
} |
|
var defaultWeekdaysMinRegex = matchWord; |
export function weekdaysMinRegex (isStrict) { |
if (this._weekdaysParseExact) { |
if (!hasOwnProp(this, '_weekdaysRegex')) { |
computeWeekdaysParse.call(this); |
} |
if (isStrict) { |
return this._weekdaysMinStrictRegex; |
} else { |
return this._weekdaysMinRegex; |
} |
} else { |
if (!hasOwnProp(this, '_weekdaysMinRegex')) { |
this._weekdaysMinRegex = defaultWeekdaysMinRegex; |
} |
return this._weekdaysMinStrictRegex && isStrict ? |
this._weekdaysMinStrictRegex : this._weekdaysMinRegex; |
} |
} |
|
|
function computeWeekdaysParse () { |
function cmpLenRev(a, b) { |
return b.length - a.length; |
} |
|
var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [], |
i, mom, minp, shortp, longp; |
for (i = 0; i < 7; i++) { |
// make the regex if we don't have it already |
mom = createUTC([2000, 1]).day(i); |
minp = this.weekdaysMin(mom, ''); |
shortp = this.weekdaysShort(mom, ''); |
longp = this.weekdays(mom, ''); |
minPieces.push(minp); |
shortPieces.push(shortp); |
longPieces.push(longp); |
mixedPieces.push(minp); |
mixedPieces.push(shortp); |
mixedPieces.push(longp); |
} |
// Sorting makes sure if one weekday (or abbr) is a prefix of another it |
// will match the longer piece. |
minPieces.sort(cmpLenRev); |
shortPieces.sort(cmpLenRev); |
longPieces.sort(cmpLenRev); |
mixedPieces.sort(cmpLenRev); |
for (i = 0; i < 7; i++) { |
shortPieces[i] = regexEscape(shortPieces[i]); |
longPieces[i] = regexEscape(longPieces[i]); |
mixedPieces[i] = regexEscape(mixedPieces[i]); |
} |
|
this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i'); |
this._weekdaysShortRegex = this._weekdaysRegex; |
this._weekdaysMinRegex = this._weekdaysRegex; |
|
this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i'); |
this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i'); |
this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i'); |
} |
/pack-rat/003_pack_rat/pack-rat/bower_components/moment/src/lib/units/hour.js |
@@ -0,0 +1,144 @@ |
import { makeGetSet } from '../moment/get-set'; |
import { addFormatToken } from '../format/format'; |
import { addUnitAlias } from './aliases'; |
import { addUnitPriority } from './priorities'; |
import { addRegexToken, match1to2, match2, match3to4, match5to6 } from '../parse/regex'; |
import { addParseToken } from '../parse/token'; |
import { HOUR, MINUTE, SECOND } from './constants'; |
import toInt from '../utils/to-int'; |
import zeroFill from '../utils/zero-fill'; |
import getParsingFlags from '../create/parsing-flags'; |
|
// FORMATTING |
|
function hFormat() { |
return this.hours() % 12 || 12; |
} |
|
function kFormat() { |
return this.hours() || 24; |
} |
|
addFormatToken('H', ['HH', 2], 0, 'hour'); |
addFormatToken('h', ['hh', 2], 0, hFormat); |
addFormatToken('k', ['kk', 2], 0, kFormat); |
|
addFormatToken('hmm', 0, 0, function () { |
return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2); |
}); |
|
addFormatToken('hmmss', 0, 0, function () { |
return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) + |
zeroFill(this.seconds(), 2); |
}); |
|
addFormatToken('Hmm', 0, 0, function () { |
return '' + this.hours() + zeroFill(this.minutes(), 2); |
}); |
|
addFormatToken('Hmmss', 0, 0, function () { |
return '' + this.hours() + zeroFill(this.minutes(), 2) + |
zeroFill(this.seconds(), 2); |
}); |
|
function meridiem (token, lowercase) { |
addFormatToken(token, 0, 0, function () { |
return this.localeData().meridiem(this.hours(), this.minutes(), lowercase); |
}); |
} |
|
meridiem('a', true); |
meridiem('A', false); |
|
// ALIASES |
|
addUnitAlias('hour', 'h'); |
|
// PRIORITY |
addUnitPriority('hour', 13); |
|
// PARSING |
|
function matchMeridiem (isStrict, locale) { |
return locale._meridiemParse; |
} |
|
addRegexToken('a', matchMeridiem); |
addRegexToken('A', matchMeridiem); |
addRegexToken('H', match1to2); |
addRegexToken('h', match1to2); |
addRegexToken('k', match1to2); |
addRegexToken('HH', match1to2, match2); |
addRegexToken('hh', match1to2, match2); |
addRegexToken('kk', match1to2, match2); |
|
addRegexToken('hmm', match3to4); |
addRegexToken('hmmss', match5to6); |
addRegexToken('Hmm', match3to4); |
addRegexToken('Hmmss', match5to6); |
|
addParseToken(['H', 'HH'], HOUR); |
addParseToken(['k', 'kk'], function (input, array, config) { |
var kInput = toInt(input); |
array[HOUR] = kInput === 24 ? 0 : kInput; |
}); |
addParseToken(['a', 'A'], function (input, array, config) { |
config._isPm = config._locale.isPM(input); |
config._meridiem = input; |
}); |
addParseToken(['h', 'hh'], function (input, array, config) { |
array[HOUR] = toInt(input); |
getParsingFlags(config).bigHour = true; |
}); |
addParseToken('hmm', function (input, array, config) { |
var pos = input.length - 2; |
array[HOUR] = toInt(input.substr(0, pos)); |
array[MINUTE] = toInt(input.substr(pos)); |
getParsingFlags(config).bigHour = true; |
}); |
addParseToken('hmmss', function (input, array, config) { |
var pos1 = input.length - 4; |
var pos2 = input.length - 2; |
array[HOUR] = toInt(input.substr(0, pos1)); |
array[MINUTE] = toInt(input.substr(pos1, 2)); |
array[SECOND] = toInt(input.substr(pos2)); |
getParsingFlags(config).bigHour = true; |
}); |
addParseToken('Hmm', function (input, array, config) { |
var pos = input.length - 2; |
array[HOUR] = toInt(input.substr(0, pos)); |
array[MINUTE] = toInt(input.substr(pos)); |
}); |
addParseToken('Hmmss', function (input, array, config) { |
var pos1 = input.length - 4; |
var pos2 = input.length - 2; |
array[HOUR] = toInt(input.substr(0, pos1)); |
array[MINUTE] = toInt(input.substr(pos1, 2)); |
array[SECOND] = toInt(input.substr(pos2)); |
}); |
|
// LOCALES |
|
export function localeIsPM (input) { |
// IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays |
// Using charAt should be more compatible. |
return ((input + '').toLowerCase().charAt(0) === 'p'); |
} |
|
export var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i; |
export function localeMeridiem (hours, minutes, isLower) { |
if (hours > 11) { |
return isLower ? 'pm' : 'PM'; |
} else { |
return isLower ? 'am' : 'AM'; |
} |
} |
|
|
// MOMENTS |
|
// Setting the hour should keep the time, because the user explicitly |
// specified which hour he wants. So trying to maintain the same hour (in |
// a new timezone) makes sense. Adding/subtracting hours does not follow |
// this rule. |
export var getSetHour = makeGetSet('Hours', true); |
/pack-rat/003_pack_rat/pack-rat/bower_components/moment/src/lib/units/millisecond.js |
@@ -0,0 +1,69 @@ |
import { makeGetSet } from '../moment/get-set'; |
import { addFormatToken } from '../format/format'; |
import { addUnitAlias } from './aliases'; |
import { addUnitPriority } from './priorities'; |
import { addRegexToken, match1, match2, match3, match1to3, matchUnsigned } from '../parse/regex'; |
import { addParseToken } from '../parse/token'; |
import { MILLISECOND } from './constants'; |
import toInt from '../utils/to-int'; |
|
// FORMATTING |
|
addFormatToken('S', 0, 0, function () { |
return ~~(this.millisecond() / 100); |
}); |
|
addFormatToken(0, ['SS', 2], 0, function () { |
return ~~(this.millisecond() / 10); |
}); |
|
addFormatToken(0, ['SSS', 3], 0, 'millisecond'); |
addFormatToken(0, ['SSSS', 4], 0, function () { |
return this.millisecond() * 10; |
}); |
addFormatToken(0, ['SSSSS', 5], 0, function () { |
return this.millisecond() * 100; |
}); |
addFormatToken(0, ['SSSSSS', 6], 0, function () { |
return this.millisecond() * 1000; |
}); |
addFormatToken(0, ['SSSSSSS', 7], 0, function () { |
return this.millisecond() * 10000; |
}); |
addFormatToken(0, ['SSSSSSSS', 8], 0, function () { |
return this.millisecond() * 100000; |
}); |
addFormatToken(0, ['SSSSSSSSS', 9], 0, function () { |
return this.millisecond() * 1000000; |
}); |
|
|
// ALIASES |
|
addUnitAlias('millisecond', 'ms'); |
|
// PRIORITY |
|
addUnitPriority('millisecond', 16); |
|
// PARSING |
|
addRegexToken('S', match1to3, match1); |
addRegexToken('SS', match1to3, match2); |
addRegexToken('SSS', match1to3, match3); |
|
var token; |
for (token = 'SSSS'; token.length <= 9; token += 'S') { |
addRegexToken(token, matchUnsigned); |
} |
|
function parseMs(input, array) { |
array[MILLISECOND] = toInt(('0.' + input) * 1000); |
} |
|
for (token = 'S'; token.length <= 9; token += 'S') { |
addParseToken(token, parseMs); |
} |
// MOMENTS |
|
export var getSetMillisecond = makeGetSet('Milliseconds', false); |
/pack-rat/003_pack_rat/pack-rat/bower_components/moment/src/lib/units/month.js |
@@ -0,0 +1,283 @@ |
import { get } from '../moment/get-set'; |
import hasOwnProp from '../utils/has-own-prop'; |
import { addFormatToken } from '../format/format'; |
import { addUnitAlias } from './aliases'; |
import { addUnitPriority } from './priorities'; |
import { addRegexToken, match1to2, match2, matchWord, regexEscape } from '../parse/regex'; |
import { addParseToken } from '../parse/token'; |
import { hooks } from '../utils/hooks'; |
import { MONTH } from './constants'; |
import toInt from '../utils/to-int'; |
import isArray from '../utils/is-array'; |
import isNumber from '../utils/is-number'; |
import indexOf from '../utils/index-of'; |
import { createUTC } from '../create/utc'; |
import getParsingFlags from '../create/parsing-flags'; |
|
export function daysInMonth(year, month) { |
return new Date(Date.UTC(year, month + 1, 0)).getUTCDate(); |
} |
|
// FORMATTING |
|
addFormatToken('M', ['MM', 2], 'Mo', function () { |
return this.month() + 1; |
}); |
|
addFormatToken('MMM', 0, 0, function (format) { |
return this.localeData().monthsShort(this, format); |
}); |
|
addFormatToken('MMMM', 0, 0, function (format) { |
return this.localeData().months(this, format); |
}); |
|
// ALIASES |
|
addUnitAlias('month', 'M'); |
|
// PRIORITY |
|
addUnitPriority('month', 8); |
|
// PARSING |
|
addRegexToken('M', match1to2); |
addRegexToken('MM', match1to2, match2); |
addRegexToken('MMM', function (isStrict, locale) { |
return locale.monthsShortRegex(isStrict); |
}); |
addRegexToken('MMMM', function (isStrict, locale) { |
return locale.monthsRegex(isStrict); |
}); |
|
addParseToken(['M', 'MM'], function (input, array) { |
array[MONTH] = toInt(input) - 1; |
}); |
|
addParseToken(['MMM', 'MMMM'], function (input, array, config, token) { |
var month = config._locale.monthsParse(input, token, config._strict); |
// if we didn't find a month name, mark the date as invalid. |
if (month != null) { |
array[MONTH] = month; |
} else { |
getParsingFlags(config).invalidMonth = input; |
} |
}); |
|
// LOCALES |
|
var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/; |
export var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'); |
export function localeMonths (m, format) { |
if (!m) { |
return isArray(this._months) ? this._months : |
this._months['standalone']; |
} |
return isArray(this._months) ? this._months[m.month()] : |
this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()]; |
} |
|
export var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'); |
export function localeMonthsShort (m, format) { |
if (!m) { |
return isArray(this._monthsShort) ? this._monthsShort : |
this._monthsShort['standalone']; |
} |
return isArray(this._monthsShort) ? this._monthsShort[m.month()] : |
this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()]; |
} |
|
function handleStrictParse(monthName, format, strict) { |
var i, ii, mom, llc = monthName.toLocaleLowerCase(); |
if (!this._monthsParse) { |
// this is not used |
this._monthsParse = []; |
this._longMonthsParse = []; |
this._shortMonthsParse = []; |
for (i = 0; i < 12; ++i) { |
mom = createUTC([2000, i]); |
this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase(); |
this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase(); |
} |
} |
|
if (strict) { |
if (format === 'MMM') { |
ii = indexOf.call(this._shortMonthsParse, llc); |
return ii !== -1 ? ii : null; |
} else { |
ii = indexOf.call(this._longMonthsParse, llc); |
return ii !== -1 ? ii : null; |
} |
} else { |
if (format === 'MMM') { |
ii = indexOf.call(this._shortMonthsParse, llc); |
if (ii !== -1) { |
return ii; |
} |
ii = indexOf.call(this._longMonthsParse, llc); |
return ii !== -1 ? ii : null; |
} else { |
ii = indexOf.call(this._longMonthsParse, llc); |
if (ii !== -1) { |
return ii; |
} |
ii = indexOf.call(this._shortMonthsParse, llc); |
return ii !== -1 ? ii : null; |
} |
} |
} |
|
export function localeMonthsParse (monthName, format, strict) { |
var i, mom, regex; |
|
if (this._monthsParseExact) { |
return handleStrictParse.call(this, monthName, format, strict); |
} |
|
if (!this._monthsParse) { |
this._monthsParse = []; |
this._longMonthsParse = []; |
this._shortMonthsParse = []; |
} |
|
// TODO: add sorting |
// Sorting makes sure if one month (or abbr) is a prefix of another |
// see sorting in computeMonthsParse |
for (i = 0; i < 12; i++) { |
// make the regex if we don't have it already |
mom = createUTC([2000, i]); |
if (strict && !this._longMonthsParse[i]) { |
this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i'); |
this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i'); |
} |
if (!strict && !this._monthsParse[i]) { |
regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, ''); |
this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i'); |
} |
// test the regex |
if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) { |
return i; |
} else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) { |
return i; |
} else if (!strict && this._monthsParse[i].test(monthName)) { |
return i; |
} |
} |
} |
|
// MOMENTS |
|
export function setMonth (mom, value) { |
var dayOfMonth; |
|
if (!mom.isValid()) { |
// No op |
return mom; |
} |
|
if (typeof value === 'string') { |
if (/^\d+$/.test(value)) { |
value = toInt(value); |
} else { |
value = mom.localeData().monthsParse(value); |
// TODO: Another silent failure? |
if (!isNumber(value)) { |
return mom; |
} |
} |
} |
|
dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value)); |
mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth); |
return mom; |
} |
|
export function getSetMonth (value) { |
if (value != null) { |
setMonth(this, value); |
hooks.updateOffset(this, true); |
return this; |
} else { |
return get(this, 'Month'); |
} |
} |
|
export function getDaysInMonth () { |
return daysInMonth(this.year(), this.month()); |
} |
|
var defaultMonthsShortRegex = matchWord; |
export function monthsShortRegex (isStrict) { |
if (this._monthsParseExact) { |
if (!hasOwnProp(this, '_monthsRegex')) { |
computeMonthsParse.call(this); |
} |
if (isStrict) { |
return this._monthsShortStrictRegex; |
} else { |
return this._monthsShortRegex; |
} |
} else { |
if (!hasOwnProp(this, '_monthsShortRegex')) { |
this._monthsShortRegex = defaultMonthsShortRegex; |
} |
return this._monthsShortStrictRegex && isStrict ? |
this._monthsShortStrictRegex : this._monthsShortRegex; |
} |
} |
|
var defaultMonthsRegex = matchWord; |
export function monthsRegex (isStrict) { |
if (this._monthsParseExact) { |
if (!hasOwnProp(this, '_monthsRegex')) { |
computeMonthsParse.call(this); |
} |
if (isStrict) { |
return this._monthsStrictRegex; |
} else { |
return this._monthsRegex; |
} |
} else { |
if (!hasOwnProp(this, '_monthsRegex')) { |
this._monthsRegex = defaultMonthsRegex; |
} |
return this._monthsStrictRegex && isStrict ? |
this._monthsStrictRegex : this._monthsRegex; |
} |
} |
|
function computeMonthsParse () { |
function cmpLenRev(a, b) { |
return b.length - a.length; |
} |
|
var shortPieces = [], longPieces = [], mixedPieces = [], |
i, mom; |
for (i = 0; i < 12; i++) { |
// make the regex if we don't have it already |
mom = createUTC([2000, i]); |
shortPieces.push(this.monthsShort(mom, '')); |
longPieces.push(this.months(mom, '')); |
mixedPieces.push(this.months(mom, '')); |
mixedPieces.push(this.monthsShort(mom, '')); |
} |
// Sorting makes sure if one month (or abbr) is a prefix of another it |
// will match the longer piece. |
shortPieces.sort(cmpLenRev); |
longPieces.sort(cmpLenRev); |
mixedPieces.sort(cmpLenRev); |
for (i = 0; i < 12; i++) { |
shortPieces[i] = regexEscape(shortPieces[i]); |
longPieces[i] = regexEscape(longPieces[i]); |
} |
for (i = 0; i < 24; i++) { |
mixedPieces[i] = regexEscape(mixedPieces[i]); |
} |
|
this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i'); |
this._monthsShortRegex = this._monthsRegex; |
this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i'); |
this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i'); |
} |
/pack-rat/003_pack_rat/pack-rat/bower_components/moment/src/lib/units/offset.js |
@@ -0,0 +1,235 @@ |
import zeroFill from '../utils/zero-fill'; |
import { createDuration } from '../duration/create'; |
import { addSubtract } from '../moment/add-subtract'; |
import { isMoment, copyConfig } from '../moment/constructor'; |
import { addFormatToken } from '../format/format'; |
import { addRegexToken, matchOffset, matchShortOffset } from '../parse/regex'; |
import { addParseToken } from '../parse/token'; |
import { createLocal } from '../create/local'; |
import { prepareConfig } from '../create/from-anything'; |
import { createUTC } from '../create/utc'; |
import isDate from '../utils/is-date'; |
import toInt from '../utils/to-int'; |
import isUndefined from '../utils/is-undefined'; |
import compareArrays from '../utils/compare-arrays'; |
import { hooks } from '../utils/hooks'; |
|
// FORMATTING |
|
function offset (token, separator) { |
addFormatToken(token, 0, 0, function () { |
var offset = this.utcOffset(); |
var sign = '+'; |
if (offset < 0) { |
offset = -offset; |
sign = '-'; |
} |
return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2); |
}); |
} |
|
offset('Z', ':'); |
offset('ZZ', ''); |
|
// PARSING |
|
addRegexToken('Z', matchShortOffset); |
addRegexToken('ZZ', matchShortOffset); |
addParseToken(['Z', 'ZZ'], function (input, array, config) { |
config._useUTC = true; |
config._tzm = offsetFromString(matchShortOffset, input); |
}); |
|
// HELPERS |
|
// timezone chunker |
// '+10:00' > ['10', '00'] |
// '-1530' > ['-15', '30'] |
var chunkOffset = /([\+\-]|\d\d)/gi; |
|
function offsetFromString(matcher, string) { |
var matches = (string || '').match(matcher); |
|
if (matches === null) { |
return null; |
} |
|
var chunk = matches[matches.length - 1] || []; |
var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0]; |
var minutes = +(parts[1] * 60) + toInt(parts[2]); |
|
return minutes === 0 ? |
0 : |
parts[0] === '+' ? minutes : -minutes; |
} |
|
// Return a moment from input, that is local/utc/zone equivalent to model. |
export function cloneWithOffset(input, model) { |
var res, diff; |
if (model._isUTC) { |
res = model.clone(); |
diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf(); |
// Use low-level api, because this fn is low-level api. |
res._d.setTime(res._d.valueOf() + diff); |
hooks.updateOffset(res, false); |
return res; |
} else { |
return createLocal(input).local(); |
} |
} |
|
function getDateOffset (m) { |
// On Firefox.24 Date#getTimezoneOffset returns a floating point. |
// https://github.com/moment/moment/pull/1871 |
return -Math.round(m._d.getTimezoneOffset() / 15) * 15; |
} |
|
// HOOKS |
|
// This function will be called whenever a moment is mutated. |
// It is intended to keep the offset in sync with the timezone. |
hooks.updateOffset = function () {}; |
|
// MOMENTS |
|
// keepLocalTime = true means only change the timezone, without |
// affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]--> |
// 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset |
// +0200, so we adjust the time as needed, to be valid. |
// |
// Keeping the time actually adds/subtracts (one hour) |
// from the actual represented time. That is why we call updateOffset |
// a second time. In case it wants us to change the offset again |
// _changeInProgress == true case, then we have to adjust, because |
// there is no such time in the given timezone. |
export function getSetOffset (input, keepLocalTime, keepMinutes) { |
var offset = this._offset || 0, |
localAdjust; |
if (!this.isValid()) { |
return input != null ? this : NaN; |
} |
if (input != null) { |
if (typeof input === 'string') { |
input = offsetFromString(matchShortOffset, input); |
if (input === null) { |
return this; |
} |
} else if (Math.abs(input) < 16 && !keepMinutes) { |
input = input * 60; |
} |
if (!this._isUTC && keepLocalTime) { |
localAdjust = getDateOffset(this); |
} |
this._offset = input; |
this._isUTC = true; |
if (localAdjust != null) { |
this.add(localAdjust, 'm'); |
} |
if (offset !== input) { |
if (!keepLocalTime || this._changeInProgress) { |
addSubtract(this, createDuration(input - offset, 'm'), 1, false); |
} else if (!this._changeInProgress) { |
this._changeInProgress = true; |
hooks.updateOffset(this, true); |
this._changeInProgress = null; |
} |
} |
return this; |
} else { |
return this._isUTC ? offset : getDateOffset(this); |
} |
} |
|
export function getSetZone (input, keepLocalTime) { |
if (input != null) { |
if (typeof input !== 'string') { |
input = -input; |
} |
|
this.utcOffset(input, keepLocalTime); |
|
return this; |
} else { |
return -this.utcOffset(); |
} |
} |
|
export function setOffsetToUTC (keepLocalTime) { |
return this.utcOffset(0, keepLocalTime); |
} |
|
export function setOffsetToLocal (keepLocalTime) { |
if (this._isUTC) { |
this.utcOffset(0, keepLocalTime); |
this._isUTC = false; |
|
if (keepLocalTime) { |
this.subtract(getDateOffset(this), 'm'); |
} |
} |
return this; |
} |
|
export function setOffsetToParsedOffset () { |
if (this._tzm != null) { |
this.utcOffset(this._tzm, false, true); |
} else if (typeof this._i === 'string') { |
var tZone = offsetFromString(matchOffset, this._i); |
if (tZone != null) { |
this.utcOffset(tZone); |
} |
else { |
this.utcOffset(0, true); |
} |
} |
return this; |
} |
|
export function hasAlignedHourOffset (input) { |
if (!this.isValid()) { |
return false; |
} |
input = input ? createLocal(input).utcOffset() : 0; |
|
return (this.utcOffset() - input) % 60 === 0; |
} |
|
export function isDaylightSavingTime () { |
return ( |
this.utcOffset() > this.clone().month(0).utcOffset() || |
this.utcOffset() > this.clone().month(5).utcOffset() |
); |
} |
|
export function isDaylightSavingTimeShifted () { |
if (!isUndefined(this._isDSTShifted)) { |
return this._isDSTShifted; |
} |
|
var c = {}; |
|
copyConfig(c, this); |
c = prepareConfig(c); |
|
if (c._a) { |
var other = c._isUTC ? createUTC(c._a) : createLocal(c._a); |
this._isDSTShifted = this.isValid() && |
compareArrays(c._a, other.toArray()) > 0; |
} else { |
this._isDSTShifted = false; |
} |
|
return this._isDSTShifted; |
} |
|
export function isLocal () { |
return this.isValid() ? !this._isUTC : false; |
} |
|
export function isUtcOffset () { |
return this.isValid() ? this._isUTC : false; |
} |
|
export function isUtc () { |
return this.isValid() ? this._isUTC && this._offset === 0 : false; |
} |
/pack-rat/003_pack_rat/pack-rat/bower_components/moment/src/lib/units/week-year.js |
@@ -0,0 +1,107 @@ |
import { addFormatToken } from '../format/format'; |
import { addUnitAlias } from './aliases'; |
import { addUnitPriority } from './priorities'; |
import { addRegexToken, match1to2, match1to4, match1to6, match2, match4, match6, matchSigned } from '../parse/regex'; |
import { addWeekParseToken } from '../parse/token'; |
import { weekOfYear, weeksInYear, dayOfYearFromWeeks } from './week-calendar-utils'; |
import toInt from '../utils/to-int'; |
import { hooks } from '../utils/hooks'; |
import { createLocal } from '../create/local'; |
import { createUTCDate } from '../create/date-from-array'; |
|
// FORMATTING |
|
addFormatToken(0, ['gg', 2], 0, function () { |
return this.weekYear() % 100; |
}); |
|
addFormatToken(0, ['GG', 2], 0, function () { |
return this.isoWeekYear() % 100; |
}); |
|
function addWeekYearFormatToken (token, getter) { |
addFormatToken(0, [token, token.length], 0, getter); |
} |
|
addWeekYearFormatToken('gggg', 'weekYear'); |
addWeekYearFormatToken('ggggg', 'weekYear'); |
addWeekYearFormatToken('GGGG', 'isoWeekYear'); |
addWeekYearFormatToken('GGGGG', 'isoWeekYear'); |
|
// ALIASES |
|
addUnitAlias('weekYear', 'gg'); |
addUnitAlias('isoWeekYear', 'GG'); |
|
// PRIORITY |
|
addUnitPriority('weekYear', 1); |
addUnitPriority('isoWeekYear', 1); |
|
|
// PARSING |
|
addRegexToken('G', matchSigned); |
addRegexToken('g', matchSigned); |
addRegexToken('GG', match1to2, match2); |
addRegexToken('gg', match1to2, match2); |
addRegexToken('GGGG', match1to4, match4); |
addRegexToken('gggg', match1to4, match4); |
addRegexToken('GGGGG', match1to6, match6); |
addRegexToken('ggggg', match1to6, match6); |
|
addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) { |
week[token.substr(0, 2)] = toInt(input); |
}); |
|
addWeekParseToken(['gg', 'GG'], function (input, week, config, token) { |
week[token] = hooks.parseTwoDigitYear(input); |
}); |
|
// MOMENTS |
|
export function getSetWeekYear (input) { |
return getSetWeekYearHelper.call(this, |
input, |
this.week(), |
this.weekday(), |
this.localeData()._week.dow, |
this.localeData()._week.doy); |
} |
|
export function getSetISOWeekYear (input) { |
return getSetWeekYearHelper.call(this, |
input, this.isoWeek(), this.isoWeekday(), 1, 4); |
} |
|
export function getISOWeeksInYear () { |
return weeksInYear(this.year(), 1, 4); |
} |
|
export function getWeeksInYear () { |
var weekInfo = this.localeData()._week; |
return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy); |
} |
|
function getSetWeekYearHelper(input, week, weekday, dow, doy) { |
var weeksTarget; |
if (input == null) { |
return weekOfYear(this, dow, doy).year; |
} else { |
weeksTarget = weeksInYear(input, dow, doy); |
if (week > weeksTarget) { |
week = weeksTarget; |
} |
return setWeekAll.call(this, input, week, weekday, dow, doy); |
} |
} |
|
function setWeekAll(weekYear, week, weekday, dow, doy) { |
var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy), |
date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear); |
|
this.year(date.getUTCFullYear()); |
this.month(date.getUTCMonth()); |
this.date(date.getUTCDate()); |
return this; |
} |
/pack-rat/003_pack_rat/pack-rat/bower_components/moment/src/lib/units/year.js |
@@ -0,0 +1,75 @@ |
import { makeGetSet } from '../moment/get-set'; |
import { addFormatToken } from '../format/format'; |
import { addUnitAlias } from './aliases'; |
import { addUnitPriority } from './priorities'; |
import { addRegexToken, match1to2, match1to4, match1to6, match2, match4, match6, matchSigned } from '../parse/regex'; |
import { addParseToken } from '../parse/token'; |
import { hooks } from '../utils/hooks'; |
import { YEAR } from './constants'; |
import toInt from '../utils/to-int'; |
|
// FORMATTING |
|
addFormatToken('Y', 0, 0, function () { |
var y = this.year(); |
return y <= 9999 ? '' + y : '+' + y; |
}); |
|
addFormatToken(0, ['YY', 2], 0, function () { |
return this.year() % 100; |
}); |
|
addFormatToken(0, ['YYYY', 4], 0, 'year'); |
addFormatToken(0, ['YYYYY', 5], 0, 'year'); |
addFormatToken(0, ['YYYYYY', 6, true], 0, 'year'); |
|
// ALIASES |
|
addUnitAlias('year', 'y'); |
|
// PRIORITIES |
|
addUnitPriority('year', 1); |
|
// PARSING |
|
addRegexToken('Y', matchSigned); |
addRegexToken('YY', match1to2, match2); |
addRegexToken('YYYY', match1to4, match4); |
addRegexToken('YYYYY', match1to6, match6); |
addRegexToken('YYYYYY', match1to6, match6); |
|
addParseToken(['YYYYY', 'YYYYYY'], YEAR); |
addParseToken('YYYY', function (input, array) { |
array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input); |
}); |
addParseToken('YY', function (input, array) { |
array[YEAR] = hooks.parseTwoDigitYear(input); |
}); |
addParseToken('Y', function (input, array) { |
array[YEAR] = parseInt(input, 10); |
}); |
|
// HELPERS |
|
export function daysInYear(year) { |
return isLeapYear(year) ? 366 : 365; |
} |
|
function isLeapYear(year) { |
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; |
} |
|
// HOOKS |
|
hooks.parseTwoDigitYear = function (input) { |
return toInt(input) + (toInt(input) > 68 ? 1900 : 2000); |
}; |
|
// MOMENTS |
|
export var getSetYear = makeGetSet('FullYear', true); |
|
export function getIsLeapYear () { |
return isLeapYear(this.year()); |
} |