Skip to content

Commit 2f8d7ae

Browse files
committed
fix(calendar): update days formatting logic to extract day part and add additional locales in sample
1 parent a48098f commit 2f8d7ae

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

projects/igniteui-angular/calendar/src/calendar/days-view/days-view.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,8 @@ export class IgxDaysViewComponent extends IgxCalendarBaseDirective implements Af
446446
*/
447447
public formattedDate(value: Date): string {
448448
if (this.formatViews.day) {
449-
return this.formatterDay.format(value);
449+
const dateParts = this.formatterDay.formatToParts(value);
450+
return dateParts.find(part => part.type === 'day')?.value ?? value.getDate().toString();
450451
}
451452

452453
return `${value.getDate()}`;

src/app/calendar/calendar.sample.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
DateRange,
2020
DateRangeDescriptor,
2121
DateRangeType,
22+
IFormattingViews,
2223
} from 'igniteui-angular';
2324
import {
2425
Properties,
@@ -62,6 +63,12 @@ export class CalendarSampleComponent implements OnInit {
6263
year: 'numeric',
6364
};
6465

66+
protected formatViews: IFormattingViews = {
67+
day: true,
68+
month: true,
69+
year: true
70+
};
71+
6572
public panelConfig: PropertyPanelConfig = {
6673
locale: {
6774
label: 'Change Locale',
@@ -87,6 +94,10 @@ export class CalendarSampleComponent implements OnInit {
8794
{
8895
value: 'ja-JP',
8996
label: 'JP'
97+
},
98+
{
99+
value: 'zh-ZH',
100+
label: 'ZH'
90101
}
91102
],
92103
defaultValue: 'en-US'

0 commit comments

Comments
 (0)