mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-30 18:27:45 -05:00
@@ -1,16 +1,15 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { NgbDateAdapter, NgbDateStruct } from "@ng-bootstrap/ng-bootstrap";
|
||||
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()
|
||||
day: date.getDate(),
|
||||
month: date.getMonth() + 1,
|
||||
year: date.getFullYear(),
|
||||
}
|
||||
} else {
|
||||
return null
|
||||
@@ -19,7 +18,13 @@ export class ISODateAdapter extends NgbDateAdapter<string> {
|
||||
|
||||
toModel(date: NgbDateStruct | null): string | null {
|
||||
if (date) {
|
||||
return date.year.toString().padStart(4, '0') + "-" + date.month.toString().padStart(2, '0') + "-" + date.day.toString().padStart(2, '0')
|
||||
return (
|
||||
date.year.toString().padStart(4, '0') +
|
||||
'-' +
|
||||
date.month.toString().padStart(2, '0') +
|
||||
'-' +
|
||||
date.day.toString().padStart(2, '0')
|
||||
)
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
|
Reference in New Issue
Block a user