Skip to content

Commit cbf2cd0

Browse files
fix(b-calendar): use Intl.NumberFormat for formatting the number in the date buttons (closes #5171) (#5179)
* fix(b-calendar): use Intl.NumberFormat for formatting the date buttons (closes #5171) * Update calendar.js Co-authored-by: Jacob Müller <jacob.mueller.elz@gmail.com>
1 parent 5160aef commit cbf2cd0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/components/calendar/calendar.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -442,10 +442,18 @@ export const BCalendar = Vue.extend({
442442
})
443443
},
444444
formatDay() {
445-
return createDateFormatter(this.calendarLocale, {
446-
day: STR_NUMERIC,
447-
calendar: STR_GREGORY
445+
// Calendar grid day number formatter
446+
// We don't use DateTimeFormatter here as it can place extra
447+
// character(s) after the number (i.e the `zh` locale)
448+
const nf = new Intl.NumberFormat([this.computedLocale], {
449+
style: 'decimal',
450+
minimumIntegerDigits: 1,
451+
minimumFractionDigits: 0,
452+
maximumFractionDigits: 0,
453+
notation: 'standard'
448454
})
455+
// Return a formatter function instance
456+
return date => nf.format(date.getDate())
449457
},
450458
// Disabled states for the nav buttons
451459
prevDecadeDisabled() {

0 commit comments

Comments
 (0)