diff --git a/package.json b/package.json index ded2cf6..6688c47 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "multihashes": "~0.4.12", "multihashing-async": "~0.5.1", "smart-buffer": "^4.0.0", - "traverse": "~0.6.6" + "traverse": "~0.6.6", + "moment": "^2.24.0" }, "devDependencies": { "aegir": "^18.0.2", diff --git a/src/util/util.js b/src/util/util.js index a4b4a71..f442cba 100644 --- a/src/util/util.js +++ b/src/util/util.js @@ -5,6 +5,7 @@ const multihashes = require('multihashes/src/constants') const multicodecs = require('multicodec/src/base-table') const multihash = require('multihashes') const CID = require('cids') +const moment = require('moment') exports = module.exports @@ -20,7 +21,7 @@ exports.find = (buf, byte) => { } exports.parsePersonLine = (line) => { - let matched = line.match(/^(([^<]+)\s)?\s?<([^>]+)>\s?(\d+\s[+\-\d]+)?$/) + let matched = line.match(/^(([^<]+)\s)?\s?<([^>]+)>\s?(\d+\s[+\-\d]+|[\d+\-:T]+)?$/) if (matched === null) { return null } @@ -28,7 +29,7 @@ exports.parsePersonLine = (line) => { return { name: matched[2], email: matched[3], - date: matched[4] + date: matched[4] && moment.parseZone(matched[4], ['X ZZ', moment.ISO_8601]).format('X ZZ') } } @@ -39,7 +40,7 @@ exports.serializePersonLine = (node) => { } parts.push('<' + node.email + '>') if (node.date) { - parts.push(node.date) + parts.push(moment.parseZone(node.date, 'X ZZ').format()) } return parts.join(' ')