mirror of
https://github.com/zadam/trilium.git
synced 2025-11-14 18:39:01 +01:00
explicit param to keep or convert local date for enex import
This commit is contained in:
parent
a3bd15e102
commit
48a20500f8
@ -237,8 +237,8 @@ function importEnex(taskContext: TaskContext<"importNotes">, file: File, parentN
|
|||||||
|
|
||||||
function updateDates(note: BNote, utcDateCreated?: string, utcDateModified?: string) {
|
function updateDates(note: BNote, utcDateCreated?: string, utcDateModified?: string) {
|
||||||
// it's difficult to force custom dateCreated and dateModified to Note entity, so we do it post-creation with SQL
|
// it's difficult to force custom dateCreated and dateModified to Note entity, so we do it post-creation with SQL
|
||||||
const dateCreated = formatDateTimeToLocalDbFormat(utcDateCreated);
|
const dateCreated = formatDateTimeToLocalDbFormat(utcDateCreated, false);
|
||||||
const dateModified = formatDateTimeToLocalDbFormat(utcDateModified);
|
const dateModified = formatDateTimeToLocalDbFormat(utcDateModified, false);
|
||||||
sql.execute(
|
sql.execute(
|
||||||
`
|
`
|
||||||
UPDATE notes
|
UPDATE notes
|
||||||
@ -411,17 +411,23 @@ function importEnex(taskContext: TaskContext<"importNotes">, file: File, parentN
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatDateTimeToLocalDbFormat(date: Date | string | null | undefined) {
|
function formatDateTimeToLocalDbFormat(
|
||||||
if (!date) {
|
utcDateFromEnex: Date | string | null | undefined,
|
||||||
|
keepUtc: boolean) {
|
||||||
|
|
||||||
|
if (!utcDateFromEnex) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const d = dayjs(date);
|
let date = dayjs(utcDateFromEnex);
|
||||||
if (!d.isValid()) {
|
if (keepUtc) {
|
||||||
|
date = date.utc();
|
||||||
|
}
|
||||||
|
if (!date.isValid()) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
return d.format(date_utils.LOCAL_DATETIME_FORMAT);
|
return date.format(date_utils.LOCAL_DATETIME_FORMAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default { importEnex };
|
export default { importEnex };
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user