mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-16 11:36:39 +01:00
use ng-bootstrap date selector, with proper formatting/parsing according to the current locale #177
This commit is contained in:
parent
6b20177b09
commit
035b0a449b
12 changed files with 176 additions and 100 deletions
23
src-ui/src/app/utils/ngb-date-adapter.ts
Normal file
23
src-ui/src/app/utils/ngb-date-adapter.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { Injectable } from "@angular/core";
|
||||
import { NgbDateAdapter, NgbDateStruct } from "@ng-bootstrap/ng-bootstrap";
|
||||
|
||||
@Injectable()
|
||||
export class ISODateAdapter extends NgbDateAdapter<string> {
|
||||
|
||||
fromModel(value: string | null): NgbDateStruct | null {
|
||||
if (value) {
|
||||
let date = new Date(value)
|
||||
return {
|
||||
day : date.getDate(),
|
||||
month : date.getMonth() + 1,
|
||||
year : date.getFullYear()
|
||||
}
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
toModel(date: NgbDateStruct | null): string | null {
|
||||
return date ? new Date(date.year, date.month - 1, date.day).toISOString() : null
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue