mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
use created_date
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
// see https://github.com/dateutil/dateutil/issues/878 , JS Date does not
|
||||
// seem to accept these strings as valid dates so we must normalize offset
|
||||
export function normalizeDateStr(dateStr: string): string {
|
||||
return dateStr.replace(/[\+-](\d\d):\d\d:\d\d/gm, `-$1:00`)
|
||||
}
|
@@ -5,11 +5,20 @@ import { NgbDateAdapter, NgbDateStruct } from '@ng-bootstrap/ng-bootstrap'
|
||||
export class ISODateTimeAdapter 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(),
|
||||
if (value.match(/\d\d\d\d\-\d\d\-\d\d/g)) {
|
||||
const segs = value.split('-')
|
||||
return {
|
||||
year: parseInt(segs[0]),
|
||||
month: parseInt(segs[1]),
|
||||
day: parseInt(segs[2]),
|
||||
}
|
||||
} else {
|
||||
let date = new Date(value)
|
||||
return {
|
||||
day: date.getDate(),
|
||||
month: date.getMonth() + 1,
|
||||
year: date.getFullYear(),
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return null
|
||||
@@ -17,8 +26,6 @@ export class ISODateTimeAdapter extends NgbDateAdapter<string> {
|
||||
}
|
||||
|
||||
toModel(date: NgbDateStruct | null): string | null {
|
||||
return date
|
||||
? new Date(date.year, date.month - 1, date.day).toISOString()
|
||||
: null
|
||||
return date ? [date.year, date.month, date.day].join('-') : null
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user