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

8
package-lock.json generated
View File

@ -257,6 +257,14 @@
}
}
},
"@angular-material-components/moment-adapter": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@angular-material-components/moment-adapter/-/moment-adapter-6.0.0.tgz",
"integrity": "sha512-YnUfaaYIsK1xeN3D84RGc500ieh7BrgSK1DNh3abneeKGTS9es9FJPkqK3JW9P+8460YQ4hxrMMeerGLG30C5A==",
"requires": {
"tslib": "^2.1.0"
}
},
"@angular/animations": {
"version": "12.2.10",
"resolved": "https://registry.npmjs.org/@angular/animations/-/animations-12.2.10.tgz",

View File

@ -12,6 +12,7 @@
"private": true,
"dependencies": {
"@angular-material-components/datetime-picker": "^6.0.3",
"@angular-material-components/moment-adapter": "^6.0.0",
"@angular/animations": "^12.2.10",
"@angular/cdk": "^12.2.10",
"@angular/common": "^12.2.10",

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) {
@ -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 ],
})

View File

@ -45,6 +45,8 @@ import {MatTableModule} from '@angular/material/table';
import {MatMomentDateModule} from '@angular/material-moment-adapter';
import {FlexLayoutModule} from '@angular/flex-layout';
import { NgxMatMomentModule } from '@angular-material-components/moment-adapter';
import {
NgxMatDatetimePickerModule,
NgxMatNativeDateModule
@ -93,6 +95,7 @@ import { NgxMatTimepickerModule } from 'ngx-mat-timepicker';
MatTableModule,
MatMomentDateModule,
FlexLayoutModule,
NgxMatMomentModule,
NgxMatDatetimePickerModule,
NgxMatNativeDateModule,
NgxMatTimepickerModule

View File

@ -99,7 +99,6 @@ export class BorrowProvingResultDialog {
constructor(
@Inject(MAT_DIALOG_DATA) private data: any) {
this.result = JSON.parse(JSON.stringify(data));
console.log(this.result);
}
}

View File

@ -28,7 +28,7 @@
</mat-select>
</mat-form-field>
<mat-form-field>
<input matInput [ngxMatDatetimePicker]="afterPicker" [formControl]="afterFormControl"
<input matInput [ngxMatDatetimePicker]="afterPicker" readonly [formControl]="afterFormControl"
placeholder="{{'partey.timeslots.filter.after' | i18n}}">
<mat-datepicker-toggle matSuffix [for]="afterPicker"></mat-datepicker-toggle>
<ngx-mat-datetime-picker #afterPicker></ngx-mat-datetime-picker>

View File

@ -13,6 +13,7 @@ import { ParteyTimeslotsService } from '../../../services/partey.service';
import { ConfirmDialog } from '../../../ui/confirm/confirm.component';
import { I18nService } from './../../../services/i18n.service';
import { AuthService } from './../../../services/auth.service';
import * as moment from 'moment';
@Component({
selector: 'app-partey-timeslots',
@ -74,7 +75,7 @@ export class ParteyTimeslotsComponent implements OnInit {
this.ownerFormControl.setValue("");
this.filter.type = "";
this.typeFormControl.setValue("");
this.filter.after = new Date().toUTCString();
this.filter.after = moment.utc().format();
this.afterFormControl.setValue(new Date());
this.searchFormControl.valueChanges.pipe(debounceTime(500)).subscribe(value => {
@ -96,7 +97,7 @@ export class ParteyTimeslotsComponent implements OnInit {
}, (error) => { })
})
this.afterFormControl.valueChanges.subscribe((value: Date) => {
this.filter.after = value && value.toUTCString() || undefined;
this.filter.after = value && moment.utc(value).format() || undefined;
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe((data: any) => {
this.timeslots = data;
}, (error) => { })

View File

@ -209,7 +209,6 @@ export class ProfileFieldDialog {
dialogRef.afterClosed().subscribe(result => {
if (result) {
console.log(result, profileField);
profileField.blob = result;
}
});