Browse Source

fix(npm/ng-packs/theme-shared): fix date time adapter at theme-shared

pull/19221/head
Yusuf Çırak 3 years ago
parent
commit
31a5e6f671
  1. 27
      npm/ng-packs/packages/theme-shared/src/lib/adapters/date-time.adapter.ts

27
npm/ng-packs/packages/theme-shared/src/lib/adapters/date-time.adapter.ts

@ -25,32 +25,15 @@ export class DateTimeAdapter {
} }
toModel(value: Partial<NgbDateTimeStruct> | null): string { toModel(value: Partial<NgbDateTimeStruct> | null): string {
if (!value) return ''; if (!value) {
return '';
const now = new Date(); }
const newValue = {
// TODO look for strict mode errors
year: now.getUTCFullYear(),
month: now.getMonth() + 1,
day: now.getDate(),
hour: 0,
minute: 0,
second: 0,
...this.value,
...value,
} as NgbDateTimeStruct;
const date = new Date( const date = new Date(
newValue.year, Date.UTC(value.year, value.month - 1, value.day, value.hour, value.minute, value.second),
newValue.month - 1,
newValue.day,
newValue.hour,
newValue.minute,
newValue.second,
); );
return new Date(date).toISOString(); return date.toISOString();
} }
} }

Loading…
Cancel
Save