}
format = expandFormat(format, m.localeData());
-
- if (!formatFunctions[format]) {
- formatFunctions[format] = makeFormatFunction(format);
- }
+ formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
return formatFunctions[format](m);
}
};
export function longDateFormat (key) {
- var output = this._longDateFormat[key];
- if (!output && this._longDateFormat[key.toUpperCase()]) {
- output = this._longDateFormat[key.toUpperCase()].replace(/MMMM|MM|DD|dddd/g, function (val) {
- return val.slice(1);
- });
- this._longDateFormat[key] = output;
+ var format = this._longDateFormat[key],
+ formatUpper = this._longDateFormat[key.toUpperCase()];
+
+ if (format || !formatUpper) {
+ return format;
}
- return output;
+
+ this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
+ return val.slice(1);
+ });
+
+ return this._longDateFormat[key];
}
export function defineLocale (name, values) {
if (values !== null) {
values.abbr = name;
- if (!locales[name]) {
- locales[name] = new Locale();
- }
+ locales[name] = locales[name] || new Locale();
locales[name].set(values);
// backwards compat for now: also set the locale
export function localeWeekdaysParse (weekdayName) {
var i, mom, regex;
- if (!this._weekdaysParse) {
- this._weekdaysParse = [];
- }
+ this._weekdaysParse = this._weekdaysParse || [];
for (i = 0; i < 7; i++) {
// make the regex if we don't have it already
}
export function hasAlignedHourOffset (input) {
- if (!input) {
- input = 0;
- }
- else {
- input = createLocal(input).utcOffset();
- }
+ input = input ? createLocal(input).utcOffset() : 0;
return (this.utcOffset() - input) % 60 === 0;
}