From 9abe85f60b6884fdf8b88dfd7c9e0452ec02ddd4 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Tue, 16 Feb 2016 16:35:28 +0000 Subject: [PATCH] Minor tweaks to #2275 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Cleaner handling of “updated” attribute * Fixed handling of note attributes, which now get imported as custom fields * Clearer handling of ISO dates --- .../evernote/modules/enex-deserializer.js | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/plugins/tiddlywiki/evernote/modules/enex-deserializer.js b/plugins/tiddlywiki/evernote/modules/enex-deserializer.js index 914b64a68..cffd4f4ab 100644 --- a/plugins/tiddlywiki/evernote/modules/enex-deserializer.js +++ b/plugins/tiddlywiki/evernote/modules/enex-deserializer.js @@ -39,19 +39,19 @@ exports["application/enex+xml"] = function(text,fields) { type: "text/html", tags: [], text: getTextContent(noteNode,"content"), - modified: getTextContent(noteNode,"created").replace("T","").replace("Z",""), - created: getTextContent(noteNode,"created").replace("T","").replace("Z","") + modified: convertDate(getTextContent(noteNode,"created")), + created: convertDate(getTextContent(noteNode,"created")) }; $tw.utils.each(noteNode.querySelectorAll("tag"),function(tagNode) { result.tags.push(tagNode.textContent); }); - // If there's an update date, set modifiy date accordingly - $tw.utils.each(noteNode.querySelectorAll("updated"),function(modifiedNode) { - result["modified"] = modifiedNode.textContent.replace("T","").replace("Z","") + "000" ; - }); - - $tw.utils.each(noteNode.querySelectorAll("note-attributes"),function(attrNode) { + // If there's an update date, set modifiy date accordingly + var update = getTextContent(noteNode,"updated"); + if(update) { + result.modified = convertDate(update); + } + $tw.utils.each(noteNode.querySelectorAll("note-attributes>*"),function(attrNode) { result[attrNode.tagName] = attrNode.textContent; }); results.push(result); @@ -73,4 +73,8 @@ function getTextContent(node,selector) { return (node.querySelector(selector) || {}).textContent; } +function convertDate(isoDate) { + return (isoDate || "").replace("T","").replace("Z","") + "000" +} + })();