From 64c0141cb6d3cd9a918f5cba811b56de81927a91 Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Fri, 17 Apr 2020 22:03:51 -0300 Subject: [PATCH 1/2] fix(b-calendar): use Intl.NumberFormat for formatting the date buttons (closes #5171) --- src/components/calendar/calendar.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/calendar/calendar.js b/src/components/calendar/calendar.js index 5392a5a8d24..b66d2feca3d 100644 --- a/src/components/calendar/calendar.js +++ b/src/components/calendar/calendar.js @@ -442,10 +442,18 @@ export const BCalendar = Vue.extend({ }) }, formatDay() { - return createDateFormatter(this.calendarLocale, { - day: STR_NUMERIC, - calendar: STR_GREGORY + // Calendar grid day number formatter + // We don't use DateTimeFormatter here as it can place extra + // character(s) after the number (i.e the `zh` locale) + const nf = new Intl.NumberFormat([this.computedLocale], { + style: 'decimal', + minimumIntegerDigits: 1, + minimumFractionDigits: 0, + maximumFractionDigits: 0, + notation: 'standard' }) + // Return a formatter function instance + return (date => nf.format(date.getDate())) }, // Disabled states for the nav buttons prevDecadeDisabled() { From 4e8ed84b403bb1633dc92562dead0254a800cf08 Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Fri, 17 Apr 2020 22:12:03 -0300 Subject: [PATCH 2/2] Update calendar.js --- src/components/calendar/calendar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/calendar/calendar.js b/src/components/calendar/calendar.js index b66d2feca3d..9d4efaea8d5 100644 --- a/src/components/calendar/calendar.js +++ b/src/components/calendar/calendar.js @@ -453,7 +453,7 @@ export const BCalendar = Vue.extend({ notation: 'standard' }) // Return a formatter function instance - return (date => nf.format(date.getDate())) + return date => nf.format(date.getDate()) }, // Disabled states for the nav buttons prevDecadeDisabled() {