Skip to content

Commit d1219ba

Browse files
committed
docs(demos): fix i18n demo to use 24 hour format
Closes #943
1 parent 19ba58d commit d1219ba

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

projects/demos/app/demo-modules/i18n/component.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
import { Component, ChangeDetectionStrategy } from '@angular/core';
2-
import { CalendarEvent, CalendarView, DAYS_OF_WEEK } from 'angular-calendar';
2+
import {
3+
CalendarDateFormatter,
4+
CalendarEvent,
5+
CalendarView,
6+
DAYS_OF_WEEK
7+
} from 'angular-calendar';
8+
import { CustomDateFormatter } from './custom-date-formatter.provider';
39

410
@Component({
511
selector: 'mwl-demo-component',
612
changeDetection: ChangeDetectionStrategy.OnPush,
7-
templateUrl: 'template.html'
13+
templateUrl: 'template.html',
14+
providers: [
15+
{
16+
provide: CalendarDateFormatter,
17+
useClass: CustomDateFormatter
18+
}
19+
]
820
})
921
export class DemoComponent {
1022
view: CalendarView = CalendarView.Month;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { CalendarDateFormatter, DateFormatterParams } from 'angular-calendar';
2+
import { DatePipe } from '@angular/common';
3+
4+
export class CustomDateFormatter extends CalendarDateFormatter {
5+
// you can override any of the methods defined in the parent class
6+
7+
public dayViewHour({ date, locale }: DateFormatterParams): string {
8+
return new DatePipe(locale).transform(date, 'HH:mm', locale);
9+
}
10+
11+
public weekViewHour({ date, locale }: DateFormatterParams): string {
12+
return this.dayViewHour({ date, locale });
13+
}
14+
}

projects/demos/app/demo-modules/i18n/sources.ts

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ export const sources = [
66
highlighted: require('!!raw-loader!highlightjs-loader?lang=typescript!./component')
77
}
88
},
9+
{
10+
filename: 'custom-date-formatter.provider.ts',
11+
contents: {
12+
raw: require('!!raw-loader!./custom-date-formatter.provider'),
13+
highlighted: require('!!raw-loader!highlightjs-loader?lang=typescript!./custom-date-formatter.provider')
14+
}
15+
},
916
{
1017
filename: 'template.html',
1118
contents: {

0 commit comments

Comments
 (0)