Skip to content

Commit

Permalink
Use RFC3339 to format date in serializePersonLine, fixes ipfs/go-ipld…
Browse files Browse the repository at this point in the history
  • Loading branch information
sameer committed Mar 18, 2019
1 parent 4519644 commit 4b69f8e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 4 additions & 3 deletions src/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -20,15 +21,15 @@ 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
}

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')
}
}

Expand All @@ -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(' ')
Expand Down

0 comments on commit 4b69f8e

Please sign in to comment.