File tree 3 files changed +35
-2
lines changed
projects/demos/app/demo-modules/i18n
3 files changed +35
-2
lines changed Original file line number Diff line number Diff line change 1
1
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' ;
3
9
4
10
@Component ( {
5
11
selector : 'mwl-demo-component' ,
6
12
changeDetection : ChangeDetectionStrategy . OnPush ,
7
- templateUrl : 'template.html'
13
+ templateUrl : 'template.html' ,
14
+ providers : [
15
+ {
16
+ provide : CalendarDateFormatter ,
17
+ useClass : CustomDateFormatter
18
+ }
19
+ ]
8
20
} )
9
21
export class DemoComponent {
10
22
view : CalendarView = CalendarView . Month ;
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change @@ -6,6 +6,13 @@ export const sources = [
6
6
highlighted : require ( '!!raw-loader!highlightjs-loader?lang=typescript!./component' )
7
7
}
8
8
} ,
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
+ } ,
9
16
{
10
17
filename : 'template.html' ,
11
18
contents : {
You can’t perform that action at this time.
0 commit comments