OpenSlides/client/src/app/shared/date-adapter.ts
Sean Engelhardt bc0fea3310 Update to Angular 8.0.6
Updates to angular 8 and updates all used components

- removed wrapper class for ngx/pwa LocalStorrace
- removed database lock service due to bugs
- tried to work around a cycle of dependancies
- changed some structure to be more close to default angular
- removed legacy angular packages
- removed date-picker since it was not currently used and
  is not compatible anymore
- upgrade tinyMCE
2019-07-04 14:20:57 +02:00

30 lines
967 B
TypeScript

import { Injectable } from '@angular/core';
import { NativeDateAdapter } from '@angular/material/core';
/**
* A custom DateAdapter for the datetimepicker in the config. This is still not fully working and needs to be done later.
* See comments in PR #3895.
*/
@Injectable()
export class OpenSlidesDateAdapter extends NativeDateAdapter {
public format(date: Date, displayFormat: Object): string {
if (displayFormat === 'input') {
return this.toFullIso8601(date);
} else {
return date.toDateString();
}
}
private to2digit(n: number): string {
return ('00' + n).slice(-2);
}
public toFullIso8601(date: Date): string {
return (
[date.getUTCFullYear(), this.to2digit(date.getUTCMonth() + 1), this.to2digit(date.getUTCDate())].join('-') +
'T' +
[this.to2digit(date.getUTCHours()), this.to2digit(date.getUTCMinutes())].join(':')
);
}
}