mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-08-10 00:18:57 +00:00
add configuration option for changing date display in paperless #325
This commit is contained in:
8
src-ui/src/app/pipes/custom-date.pipe.spec.ts
Normal file
8
src-ui/src/app/pipes/custom-date.pipe.spec.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { CustomDatePipe } from './custom-date.pipe';
|
||||
|
||||
describe('CustomDatePipe', () => {
|
||||
it('create an instance', () => {
|
||||
const pipe = new CustomDatePipe();
|
||||
expect(pipe).toBeTruthy();
|
||||
});
|
||||
});
|
19
src-ui/src/app/pipes/custom-date.pipe.ts
Normal file
19
src-ui/src/app/pipes/custom-date.pipe.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { Inject, LOCALE_ID, Pipe, PipeTransform } from '@angular/core';
|
||||
import { SettingsService, SETTINGS_KEYS } from '../services/settings.service';
|
||||
|
||||
@Pipe({
|
||||
name: 'customDate'
|
||||
})
|
||||
export class CustomDatePipe extends DatePipe implements PipeTransform {
|
||||
|
||||
constructor(@Inject(LOCALE_ID) locale: string, private settings: SettingsService) {
|
||||
super(settings.get(SETTINGS_KEYS.DATE_LOCALE) || locale)
|
||||
|
||||
}
|
||||
|
||||
transform(value: any, format?: string, timezone?: string, locale?: string): string | null {
|
||||
return super.transform(value, format || this.settings.get(SETTINGS_KEYS.DATE_FORMAT), timezone, locale)
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user