fixed locale dates

This commit is contained in:
_Bastler
2021-11-23 20:21:25 +01:00
parent 01f399e547
commit f3a7017320
8 changed files with 85 additions and 49 deletions
+27 -2
View File
@@ -62,6 +62,9 @@ import { DurationpickerComponent } from './ui/durationpicker/durationpicker.comp
import { InviteCodeComponent } from './pages/invites/code/code.component';
import { InviteEditComponent } from './pages/invites/edit/invite.edit';
import { MatPaginatorIntl } from '@angular/material/paginator';
import { NgxMatDateAdapter, NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker';
import { MAT_DATE_LOCALE } from '@angular/material/core';
import { NgxMatMomentAdapter } from '@angular-material-components/moment-adapter';
export function init_app(i18n: I18nService) {
@@ -82,7 +85,7 @@ export class XhrInterceptor implements HttpInterceptor {
@NgModule({
declarations: [
AutofocusDirective,
I18nPipe,I18nEmptyPipe,
I18nPipe, I18nEmptyPipe,
MomentPipe,
MainComponent,
AppComponent,
@@ -133,7 +136,7 @@ export class XhrInterceptor implements HttpInterceptor {
FormsModule,
ReactiveFormsModule,
QrCodeModule,
],
exports: [ MaterialModule ],
providers: [ { provide: APP_INITIALIZER, useFactory: init_app, deps: [ I18nService ], multi: true }, { provide: HTTP_INTERCEPTORS, useClass: XhrInterceptor, multi: true }, DatePipe,
@@ -143,6 +146,28 @@ export class XhrInterceptor implements HttpInterceptor {
service.injectI18n(i18n)
return service;
}, deps: [ I18nService ]
},
{
provide: NgxMatDateAdapter,
useClass: NgxMatMomentAdapter,
useFactory: (i18n: I18nService) => {
return new NgxMatMomentAdapter(i18n.getLocale());
}, deps: [ I18nService ]
}, {
provide: NGX_MAT_DATE_FORMATS, useFactory: (i18n: I18nService) => {
const datetimeformat = i18n.get('format.datetime', []);
return {
parse: {
dateInput: "l, LTS"
},
display: {
dateInput: datetimeformat,
monthYearLabel: "MMM YYYY",
dateA11yLabel: "LL",
monthYearA11yLabel: "MMMM YYYY"
}
};
}, deps: [ I18nService ]
} ],
bootstrap: [ AppComponent ],
})