Skip to content

Commit

Permalink
feat(datepicker): added locale option to Datepicker Configuration (#2560
Browse files Browse the repository at this point in the history
)

* feat(datepicker): added locale option to Datepicker Configuration

fixes #455
  • Loading branch information
valorkin authored Sep 1, 2017
1 parent 2bcc1d2 commit 8ac689a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/datepicker/date-formatter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { formatDate } from '../bs-moment/format';

export class DateFormatter {
public format(date: Date, format: string): string {
return formatDate(date, format);
public format(date: Date, format: string, locale: string): string {
return formatDate(date, format, locale);
}
}
3 changes: 2 additions & 1 deletion src/datepicker/datepicker-inner.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { DateFormatter } from './date-formatter';
`
})
export class DatePickerInnerComponent implements OnInit, OnChanges {
@Input() locale: string;
@Input() public datepickerMode: string;
@Input() public startingDay: number;
@Input() public yearRange: number;
Expand Down Expand Up @@ -181,7 +182,7 @@ export class DatePickerInnerComponent implements OnInit, OnChanges {
}

public dateFilter(date: Date, format: string): string {
return this.dateFormatter.format(date, format);
return this.dateFormatter.format(date, format, this.locale);
}

public isActive(dateObject: any): boolean {
Expand Down
1 change: 1 addition & 0 deletions src/datepicker/datepicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const DATEPICKER_CONTROL_VALUE_ACCESSOR: any = {
template: `
<datepicker-inner [activeDate]="activeDate"
(update)="onUpdate($event)"
[locale]="config.locale"
[datepickerMode]="datepickerMode"
[initDate]="initDate"
[minDate]="minDate"
Expand Down
1 change: 1 addition & 0 deletions src/datepicker/datepicker.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';

@Injectable()
export class DatepickerConfig {
locale = 'en';
public datepickerMode: string = 'day';
public startingDay: number = 0;
public yearRange: number = 20;
Expand Down

0 comments on commit 8ac689a

Please sign in to comment.