[update]
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// ANGULAR
|
||||
import { LOCALE_ID, NgModule } from "@angular/core";
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { Injectable, LOCALE_ID, NgModule } from "@angular/core";
|
||||
import { CommonModule, registerLocaleData } from "@angular/common";
|
||||
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
|
||||
|
||||
// MATERIAL
|
||||
@@ -10,7 +10,7 @@ import { MatSortModule } from "@angular/material/sort";
|
||||
import { MatProgressSpinnerModule } from "@angular/material/progress-spinner";
|
||||
import { MatCardModule } from "@angular/material/card";
|
||||
import { MatDatepickerModule } from "@angular/material/datepicker";
|
||||
import { MatNativeDateModule, MatRippleModule } from "@angular/material/core";
|
||||
import { DateAdapter, MAT_DATE_FORMATS, MatNativeDateModule, MatRippleModule, NativeDateAdapter } from "@angular/material/core";
|
||||
import { MatProgressBarModule } from "@angular/material/progress-bar";
|
||||
import { MatButtonToggleModule } from "@angular/material/button-toggle";
|
||||
import { MatGridListModule } from "@angular/material/grid-list";
|
||||
@@ -40,7 +40,36 @@ import { CanDirective } from "./utils/can.directive";
|
||||
import { AllowRoleDirective } from "./utils/allow-role.directives";
|
||||
import { CurrencyInputMaskDirective } from "./@common/utils/CurrencyInputMask";
|
||||
import { NumberOnlyDirective } from "./@common/utils/NumberOnlyDirective";
|
||||
import { ThaidatePipe } from "./@common/utils/thaidate.pipe";
|
||||
import localeTh from '@angular/common/locales/th';
|
||||
registerLocaleData(localeTh)
|
||||
@Injectable()
|
||||
export class AppDateAdapter extends NativeDateAdapter {
|
||||
format(date: Date, displayFormat: Object): string {
|
||||
let monthNamesThai = ["ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.","ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค"];
|
||||
date.setHours(7)
|
||||
let day: string = date.getDate().toLocaleString()
|
||||
day = +day < 10 ? '0' + day : day;
|
||||
let year = date.getFullYear();
|
||||
return `${day}/${monthNamesThai[date.getMonth()]}/${year + 543}`;
|
||||
}
|
||||
}
|
||||
|
||||
export const PICK_FORMATS = {
|
||||
parse: {
|
||||
dateInput: {
|
||||
month: 'short',
|
||||
year: 'numeric',
|
||||
day: 'numeric'
|
||||
}
|
||||
},
|
||||
display: {
|
||||
dateInput: 'input',
|
||||
monthYearLabel: { day: 'numeric', year: 'numeric', month: 'long' },
|
||||
dateA11yLabel: { year: 'numeric', month: 'long', day: 'numeric' },
|
||||
monthYearA11yLabel: { year: 'numeric', month: 'long' }
|
||||
}
|
||||
};
|
||||
|
||||
const MAT = [
|
||||
MatAutocompleteModule,
|
||||
@@ -104,7 +133,8 @@ const PIPES = [
|
||||
DateFormat,
|
||||
DateDiff,
|
||||
CurrencyInputMaskDirective,
|
||||
NumberOnlyDirective
|
||||
NumberOnlyDirective,
|
||||
ThaidatePipe
|
||||
];
|
||||
|
||||
const PROVIDERS: any = [
|
||||
@@ -112,7 +142,10 @@ const PROVIDERS: any = [
|
||||
provide: MAT_FORM_FIELD_DEFAULT_OPTIONS,
|
||||
useValue: appearance
|
||||
},
|
||||
{ provide: LOCALE_ID, useValue: "en-GB" }
|
||||
{ provide: LOCALE_ID, useValue: 'th-TH' },
|
||||
{ provide: MAT_DATE_FORMATS, useValue: PICK_FORMATS },
|
||||
{ provide: DateAdapter, useClass: AppDateAdapter },
|
||||
// { provide: LOCALE_ID, useValue: "en-GB" }
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
||||
Reference in New Issue
Block a user