evernote导入丢失创建和更新时间 #75

https://github.com/leanote/desktop-app/issues/75
This commit is contained in:
life
2015-10-27 13:06:46 +08:00
parent 8296c01a02
commit fcecc47b65
3 changed files with 15 additions and 3 deletions

3
node_modules/common.js generated vendored
View File

@@ -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++;

4
node_modules/note.js generated vendored
View File

@@ -56,14 +56,18 @@ var Note = {
// console.log(noteOrContent);
var date = new Date();
if (!Common.isValidDate(noteOrContent.UpdatedTime)) {
noteOrContent.UpdatedTime = date;
}
noteOrContent['IsDirty'] = true; // 已修改
noteOrContent['LocalIsDelete'] = false;
// 新建笔记, IsNew还是保存着
if(noteOrContent.IsNew) {
if (!Common.isValidDate(noteOrContent.CreatedTime)) {
noteOrContent.CreatedTime = date;
}
noteOrContent['IsTrash'] = false;
delete noteOrContent['IsNew'];
noteOrContent['LocalIsNew'] = true;

View File

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