From fcecc47b659906f2472d2ecf988ceb5f4ec1dff6 Mon Sep 17 00:00:00 2001 From: life Date: Tue, 27 Oct 2015 13:06:46 +0800 Subject: [PATCH] =?UTF-8?q?evernote=E5=AF=BC=E5=85=A5=E4=B8=A2=E5=A4=B1?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E5=92=8C=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4?= =?UTF-8?q?=20#75?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/leanote/desktop-app/issues/75 --- node_modules/common.js | 3 +++ node_modules/note.js | 8 ++++++-- public/plugins/import_evernote/import.js | 7 ++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/node_modules/common.js b/node_modules/common.js index d989b56c..a5b12dfd 100644 --- a/node_modules/common.js +++ b/node_modules/common.js @@ -48,6 +48,9 @@ var Common = { return false; }, + isValidDate: function (d) { + return Object.prototype.toString.call(d) === "[object Date]" && !isNaN(d.getTime()); + }, _uuid: 1, uuid: function() { this._uuid++; diff --git a/node_modules/note.js b/node_modules/note.js index fc4bc613..830c8424 100644 --- a/node_modules/note.js +++ b/node_modules/note.js @@ -56,14 +56,18 @@ var Note = { // console.log(noteOrContent); var date = new Date(); - noteOrContent.UpdatedTime = date; + if (!Common.isValidDate(noteOrContent.UpdatedTime)) { + noteOrContent.UpdatedTime = date; + } noteOrContent['IsDirty'] = true; // 已修改 noteOrContent['LocalIsDelete'] = false; // 新建笔记, IsNew还是保存着 if(noteOrContent.IsNew) { - noteOrContent.CreatedTime = date; + if (!Common.isValidDate(noteOrContent.CreatedTime)) { + noteOrContent.CreatedTime = date; + } noteOrContent['IsTrash'] = false; delete noteOrContent['IsNew']; noteOrContent['LocalIsNew'] = true; diff --git a/public/plugins/import_evernote/import.js b/public/plugins/import_evernote/import.js index f031f115..72afbeef 100755 --- a/public/plugins/import_evernote/import.js +++ b/public/plugins/import_evernote/import.js @@ -87,6 +87,8 @@ var Import = { // 20150206T031506Z parseEvernoteTime: function (str) { + // console.log('parseEvernoteTime'); + // console.log(str); if (!str || typeof str != 'string' || str.length != '20150206T031506Z'.length) { return new Date(); } @@ -100,7 +102,7 @@ var Import = { var d = new Date(year + '-' + month + '-' + day + ' ' + h + ':' + m + ':' + s); // invalid - if (!isNaN(d.getTime())) { + if (isNaN(d.getTime())) { return new Date(); } return d; @@ -247,6 +249,9 @@ var Import = { jsonNote.Desc = ''; jsonNote.IsMarkdown = false; + // console.log('----------'); + // console.log(jsonNote); + // 添加tags if(jsonNote.Tags && jsonNote.Tags.length > 0) { for(var h = 0; h < jsonNote.Tags.length; ++h) {