/pack-rat/003_pack_rat/pack-rat/bower_components/moment/src/lib/locale/base-config.js |
@@ -0,0 +1,44 @@ |
import { defaultCalendar } from './calendar'; |
import { defaultLongDateFormat } from './formats'; |
import { defaultInvalidDate } from './invalid'; |
import { defaultOrdinal, defaultDayOfMonthOrdinalParse } from './ordinal'; |
import { defaultRelativeTime } from './relative'; |
|
// months |
import { |
defaultLocaleMonths, |
defaultLocaleMonthsShort, |
} from '../units/month'; |
|
// week |
import { defaultLocaleWeek } from '../units/week'; |
|
// weekdays |
import { |
defaultLocaleWeekdays, |
defaultLocaleWeekdaysMin, |
defaultLocaleWeekdaysShort, |
} from '../units/day-of-week'; |
|
// meridiem |
import { defaultLocaleMeridiemParse } from '../units/hour'; |
|
export var baseConfig = { |
calendar: defaultCalendar, |
longDateFormat: defaultLongDateFormat, |
invalidDate: defaultInvalidDate, |
ordinal: defaultOrdinal, |
dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse, |
relativeTime: defaultRelativeTime, |
|
months: defaultLocaleMonths, |
monthsShort: defaultLocaleMonthsShort, |
|
week: defaultLocaleWeek, |
|
weekdays: defaultLocaleWeekdays, |
weekdaysMin: defaultLocaleWeekdaysMin, |
weekdaysShort: defaultLocaleWeekdaysShort, |
|
meridiemParse: defaultLocaleMeridiemParse |
}; |
/pack-rat/003_pack_rat/pack-rat/bower_components/moment/src/lib/locale/lists.js |
@@ -0,0 +1,93 @@ |
import isNumber from '../utils/is-number'; |
import { getLocale } from './locales'; |
import { createUTC } from '../create/utc'; |
|
function get (format, index, field, setter) { |
var locale = getLocale(); |
var utc = createUTC().set(setter, index); |
return locale[field](utc, format); |
} |
|
function listMonthsImpl (format, index, field) { |
if (isNumber(format)) { |
index = format; |
format = undefined; |
} |
|
format = format || ''; |
|
if (index != null) { |
return get(format, index, field, 'month'); |
} |
|
var i; |
var out = []; |
for (i = 0; i < 12; i++) { |
out[i] = get(format, i, field, 'month'); |
} |
return out; |
} |
|
// () |
// (5) |
// (fmt, 5) |
// (fmt) |
// (true) |
// (true, 5) |
// (true, fmt, 5) |
// (true, fmt) |
function listWeekdaysImpl (localeSorted, format, index, field) { |
if (typeof localeSorted === 'boolean') { |
if (isNumber(format)) { |
index = format; |
format = undefined; |
} |
|
format = format || ''; |
} else { |
format = localeSorted; |
index = format; |
localeSorted = false; |
|
if (isNumber(format)) { |
index = format; |
format = undefined; |
} |
|
format = format || ''; |
} |
|
var locale = getLocale(), |
shift = localeSorted ? locale._week.dow : 0; |
|
if (index != null) { |
return get(format, (index + shift) % 7, field, 'day'); |
} |
|
var i; |
var out = []; |
for (i = 0; i < 7; i++) { |
out[i] = get(format, (i + shift) % 7, field, 'day'); |
} |
return out; |
} |
|
export function listMonths (format, index) { |
return listMonthsImpl(format, index, 'months'); |
} |
|
export function listMonthsShort (format, index) { |
return listMonthsImpl(format, index, 'monthsShort'); |
} |
|
export function listWeekdays (localeSorted, format, index) { |
return listWeekdaysImpl(localeSorted, format, index, 'weekdays'); |
} |
|
export function listWeekdaysShort (localeSorted, format, index) { |
return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort'); |
} |
|
export function listWeekdaysMin (localeSorted, format, index) { |
return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin'); |
} |
/pack-rat/003_pack_rat/pack-rat/bower_components/moment/src/lib/locale/locales.js |
@@ -0,0 +1,186 @@ |
import isArray from '../utils/is-array'; |
import hasOwnProp from '../utils/has-own-prop'; |
import isUndefined from '../utils/is-undefined'; |
import compareArrays from '../utils/compare-arrays'; |
import { deprecateSimple } from '../utils/deprecate'; |
import { mergeConfigs } from './set'; |
import { Locale } from './constructor'; |
import keys from '../utils/keys'; |
|
import { baseConfig } from './base-config'; |
|
// internal storage for locale config files |
var locales = {}; |
var localeFamilies = {}; |
var globalLocale; |
|
function normalizeLocale(key) { |
return key ? key.toLowerCase().replace('_', '-') : key; |
} |
|
// pick the locale from the array |
// try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each |
// substring from most specific to least, but move to the next array item if it's a more specific variant than the current root |
function chooseLocale(names) { |
var i = 0, j, next, locale, split; |
|
while (i < names.length) { |
split = normalizeLocale(names[i]).split('-'); |
j = split.length; |
next = normalizeLocale(names[i + 1]); |
next = next ? next.split('-') : null; |
while (j > 0) { |
locale = loadLocale(split.slice(0, j).join('-')); |
if (locale) { |
return locale; |
} |
if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) { |
//the next array item is better than a shallower substring of this one |
break; |
} |
j--; |
} |
i++; |
} |
return null; |
} |
|
function loadLocale(name) { |
var oldLocale = null; |
// TODO: Find a better way to register and load all the locales in Node |
if (!locales[name] && (typeof module !== 'undefined') && |
module && module.exports) { |
try { |
oldLocale = globalLocale._abbr; |
require('./locale/' + name); |
// because defineLocale currently also sets the global locale, we |
// want to undo that for lazy loaded locales |
getSetGlobalLocale(oldLocale); |
} catch (e) { } |
} |
return locales[name]; |
} |
|
// This function will load locale and then set the global locale. If |
// no arguments are passed in, it will simply return the current global |
// locale key. |
export function getSetGlobalLocale (key, values) { |
var data; |
if (key) { |
if (isUndefined(values)) { |
data = getLocale(key); |
} |
else { |
data = defineLocale(key, values); |
} |
|
if (data) { |
// moment.duration._locale = moment._locale = data; |
globalLocale = data; |
} |
} |
|
return globalLocale._abbr; |
} |
|
export function defineLocale (name, config) { |
if (config !== null) { |
var parentConfig = baseConfig; |
config.abbr = name; |
if (locales[name] != null) { |
deprecateSimple('defineLocaleOverride', |
'use moment.updateLocale(localeName, config) to change ' + |
'an existing locale. moment.defineLocale(localeName, ' + |
'config) should only be used for creating a new locale ' + |
'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.'); |
parentConfig = locales[name]._config; |
} else if (config.parentLocale != null) { |
if (locales[config.parentLocale] != null) { |
parentConfig = locales[config.parentLocale]._config; |
} else { |
if (!localeFamilies[config.parentLocale]) { |
localeFamilies[config.parentLocale] = []; |
} |
localeFamilies[config.parentLocale].push({ |
name: name, |
config: config |
}); |
return null; |
} |
} |
locales[name] = new Locale(mergeConfigs(parentConfig, config)); |
|
if (localeFamilies[name]) { |
localeFamilies[name].forEach(function (x) { |
defineLocale(x.name, x.config); |
}); |
} |
|
// backwards compat for now: also set the locale |
// make sure we set the locale AFTER all child locales have been |
// created, so we won't end up with the child locale set. |
getSetGlobalLocale(name); |
|
|
return locales[name]; |
} else { |
// useful for testing |
delete locales[name]; |
return null; |
} |
} |
|
export function updateLocale(name, config) { |
if (config != null) { |
var locale, parentConfig = baseConfig; |
// MERGE |
if (locales[name] != null) { |
parentConfig = locales[name]._config; |
} |
config = mergeConfigs(parentConfig, config); |
locale = new Locale(config); |
locale.parentLocale = locales[name]; |
locales[name] = locale; |
|
// backwards compat for now: also set the locale |
getSetGlobalLocale(name); |
} else { |
// pass null for config to unupdate, useful for tests |
if (locales[name] != null) { |
if (locales[name].parentLocale != null) { |
locales[name] = locales[name].parentLocale; |
} else if (locales[name] != null) { |
delete locales[name]; |
} |
} |
} |
return locales[name]; |
} |
|
// returns locale data |
export function getLocale (key) { |
var locale; |
|
if (key && key._locale && key._locale._abbr) { |
key = key._locale._abbr; |
} |
|
if (!key) { |
return globalLocale; |
} |
|
if (!isArray(key)) { |
//short-circuit everything else |
locale = loadLocale(key); |
if (locale) { |
return locale; |
} |
key = [key]; |
} |
|
return chooseLocale(key); |
} |
|
export function listLocales() { |
return keys(locales); |
} |
/pack-rat/003_pack_rat/pack-rat/bower_components/moment/src/lib/locale/prototype.js |
@@ -0,0 +1,69 @@ |
import { Locale } from './constructor'; |
|
var proto = Locale.prototype; |
|
import { calendar } from './calendar'; |
import { longDateFormat } from './formats'; |
import { invalidDate } from './invalid'; |
import { ordinal } from './ordinal'; |
import { preParsePostFormat } from './pre-post-format'; |
import { relativeTime, pastFuture } from './relative'; |
import { set } from './set'; |
|
proto.calendar = calendar; |
proto.longDateFormat = longDateFormat; |
proto.invalidDate = invalidDate; |
proto.ordinal = ordinal; |
proto.preparse = preParsePostFormat; |
proto.postformat = preParsePostFormat; |
proto.relativeTime = relativeTime; |
proto.pastFuture = pastFuture; |
proto.set = set; |
|
// Month |
import { |
localeMonthsParse, |
localeMonths, |
localeMonthsShort, |
monthsRegex, |
monthsShortRegex |
} from '../units/month'; |
|
proto.months = localeMonths; |
proto.monthsShort = localeMonthsShort; |
proto.monthsParse = localeMonthsParse; |
proto.monthsRegex = monthsRegex; |
proto.monthsShortRegex = monthsShortRegex; |
|
// Week |
import { localeWeek, localeFirstDayOfYear, localeFirstDayOfWeek } from '../units/week'; |
proto.week = localeWeek; |
proto.firstDayOfYear = localeFirstDayOfYear; |
proto.firstDayOfWeek = localeFirstDayOfWeek; |
|
// Day of Week |
import { |
localeWeekdaysParse, |
localeWeekdays, |
localeWeekdaysMin, |
localeWeekdaysShort, |
|
weekdaysRegex, |
weekdaysShortRegex, |
weekdaysMinRegex |
} from '../units/day-of-week'; |
|
proto.weekdays = localeWeekdays; |
proto.weekdaysMin = localeWeekdaysMin; |
proto.weekdaysShort = localeWeekdaysShort; |
proto.weekdaysParse = localeWeekdaysParse; |
|
proto.weekdaysRegex = weekdaysRegex; |
proto.weekdaysShortRegex = weekdaysShortRegex; |
proto.weekdaysMinRegex = weekdaysMinRegex; |
|
// Hours |
import { localeIsPM, localeMeridiem } from '../units/hour'; |
|
proto.isPM = localeIsPM; |
proto.meridiem = localeMeridiem; |
/pack-rat/003_pack_rat/pack-rat/bower_components/moment/src/lib/locale/set.js |
@@ -0,0 +1,49 @@ |
import isFunction from '../utils/is-function'; |
import extend from '../utils/extend'; |
import isObject from '../utils/is-object'; |
import hasOwnProp from '../utils/has-own-prop'; |
|
export function set (config) { |
var prop, i; |
for (i in config) { |
prop = config[i]; |
if (isFunction(prop)) { |
this[i] = prop; |
} else { |
this['_' + i] = prop; |
} |
} |
this._config = config; |
// Lenient ordinal parsing accepts just a number in addition to |
// number + (possibly) stuff coming from _dayOfMonthOrdinalParse. |
// TODO: Remove "ordinalParse" fallback in next major release. |
this._dayOfMonthOrdinalParseLenient = new RegExp( |
(this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) + |
'|' + (/\d{1,2}/).source); |
} |
|
export function mergeConfigs(parentConfig, childConfig) { |
var res = extend({}, parentConfig), prop; |
for (prop in childConfig) { |
if (hasOwnProp(childConfig, prop)) { |
if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) { |
res[prop] = {}; |
extend(res[prop], parentConfig[prop]); |
extend(res[prop], childConfig[prop]); |
} else if (childConfig[prop] != null) { |
res[prop] = childConfig[prop]; |
} else { |
delete res[prop]; |
} |
} |
} |
for (prop in parentConfig) { |
if (hasOwnProp(parentConfig, prop) && |
!hasOwnProp(childConfig, prop) && |
isObject(parentConfig[prop])) { |
// make sure changes to properties don't modify parent config |
res[prop] = extend({}, res[prop]); |
} |
} |
return res; |
} |