mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-16 11:36:39 +01:00
add configuration option for changing date display in paperless #325
This commit is contained in:
parent
961354aa8a
commit
864e421cd3
14 changed files with 119 additions and 26 deletions
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)
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue