1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-23 18:53:36 +02:00

Cli: Allow setting user timestamps with "set" command

This commit is contained in:
Laurent Cozic 2019-10-11 19:49:47 +02:00
parent c98644b72f
commit 7d7975daf4
2 changed files with 9 additions and 6 deletions

View File

@ -39,7 +39,14 @@ class Command extends BaseCommand {
type_: notes[i].type_,
};
newNote[propName] = propValue;
await Note.save(newNote);
const timestamp = Date.now();
await Note.save(newNote, {
autoTimestamp: false, // No auto-timestamp because user may have provided them
updated_time: timestamp,
created_time: timestamp,
});
}
}
}

View File

@ -238,11 +238,7 @@ class BaseItem extends BaseModel {
static serialize_format(propName, propValue) {
if (['created_time', 'updated_time', 'sync_time', 'user_updated_time', 'user_created_time'].indexOf(propName) >= 0) {
if (!propValue) return '';
propValue =
`${moment
.unix(propValue / 1000)
.utc()
.format('YYYY-MM-DDTHH:mm:ss.SSS')}Z`;
propValue = `${moment.unix(propValue / 1000).utc().format('YYYY-MM-DDTHH:mm:ss.SSS')}Z`;
} else if (['title_diff', 'body_diff'].indexOf(propName) >= 0) {
if (!propValue) return '';
propValue = JSON.stringify(propValue);