Skip to content

Commit

Permalink
fix(datepicker): fix long date format (#2630)
Browse files Browse the repository at this point in the history
fixes #2611
  • Loading branch information
IlyaSurmay authored and valorkin committed Sep 14, 2017
1 parent 61e6ed9 commit 4e40497
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/bs-moment/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function expandFormat(_format: string, locale: Locale) {
const localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;

const replaceLongDateFormatTokens = (input: any) => {
return locale.longDateFormat(input) || input;
return locale.formatLongDate(input) || input;
};

localFormattingTokens.lastIndex = 0;
Expand Down
12 changes: 7 additions & 5 deletions src/bs-moment/locale/locale.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class Locale {
private _weekdaysShort: string[];
private _weekdaysMin: string[];
private _week: { dow: number; doy: number };
private _longDateFormat: {[key: string]: any};

private _ordinal: string;

Expand Down Expand Up @@ -184,20 +185,21 @@ export class Locale {
return str;
}

longDateFormat(key: string) {
const format = defaultLongDateFormat[key];
const formatUpper = defaultLongDateFormat[key.toUpperCase()];
formatLongDate(key: string) {
this._longDateFormat = this._longDateFormat ? this._longDateFormat : defaultLongDateFormat;
const format = this._longDateFormat[key];
const formatUpper = this._longDateFormat[key.toUpperCase()];

if (format || !formatUpper) {
return format;
}

defaultLongDateFormat[
this._longDateFormat[
key
] = formatUpper.replace(/MMMM|MM|DD|dddd/g, (val: string) => {
return val.slice(1);
});

return defaultLongDateFormat[key];
return this._longDateFormat[key];
}
}

1 comment on commit 4e40497

@HugoMarteau
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi ,any idea of when it will be released ? Thanks for your work !

Please sign in to comment.