} from 'rxjs/operators'
import { PaperlessDocumentSuggestions } from 'src/app/data/paperless-document-suggestions'
import { FILTER_FULLTEXT_MORELIKE } from 'src/app/data/filter-rule-type'
+import { normalizeDateStr } from 'src/app/utils/date'
@Component({
selector: 'app-document-detail',
.pipe(takeUntil(this.unsubscribeNotifier))
.subscribe((changes) => {
if (this.ogDate) {
- let newDate = new Date(changes['created'])
+ let newDate = new Date(normalizeDateStr(changes['created']))
newDate.setHours(
this.ogDate.getHours(),
this.ogDate.getMinutes(),
this.ogDate.getMilliseconds()
)
this.documentForm.patchValue(
- { created: this.formatDate(newDate) },
+ { created: newDate.toISOString() },
{ emitEvent: false }
)
}
this.updateComponent(doc)
}
- this.ogDate = new Date(doc.created)
+ this.ogDate = new Date(normalizeDateStr(doc.created.toString()))
// Initialize dirtyCheck
this.store = new BehaviorSubject({
title: doc.title,
content: doc.content,
- created: this.formatDate(this.ogDate),
+ created: this.ogDate.toISOString(),
correspondent: doc.correspondent,
document_type: doc.document_type,
archive_serial_number: doc.archive_serial_number,
tags: [...doc.tags],
})
- // ensure we're always starting with 24-char ISO8601 string
+ // start with ISO8601 string
this.documentForm.patchValue(
- { created: this.formatDate(this.ogDate) },
+ { created: this.ogDate.toISOString() },
{ emitEvent: false }
)
this.password = (event.target as HTMLInputElement).value
}
}
-
- formatDate(date: Date): string {
- return date.toISOString().split('.')[0] + 'Z'
- }
}
import { DatePipe } from '@angular/common'
import { Inject, LOCALE_ID, Pipe, PipeTransform } from '@angular/core'
import { SettingsService, SETTINGS_KEYS } from '../services/settings.service'
+import { normalizeDateStr } from '../utils/date'
const FORMAT_TO_ISO_FORMAT = {
longDate: 'y-MM-dd',
this.settings.get(SETTINGS_KEYS.DATE_LOCALE) ||
this.defaultLocale
let f = format || this.settings.get(SETTINGS_KEYS.DATE_FORMAT)
+ if (typeof value == 'string') value = normalizeDateStr(value)
if (l == 'iso-8601') {
return this.datePipe.transform(value, FORMAT_TO_ISO_FORMAT[f], timezone)
} else {