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) {