Skip to content

Commit

Permalink
Drop the moment dependency
Browse files Browse the repository at this point in the history
It takes up 3.1 MB on disk.

I also switched from Z to UTC as it’s more user-friendly.
  • Loading branch information
sindresorhus authored and novemberborn committed Jul 2, 2017
1 parent 4c14e55 commit 611e720
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 19 deletions.
11 changes: 7 additions & 4 deletions lib/complexValues/date.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const moment = require('moment')
const dateTime = require('date-time')

const constants = require('../constants')
const formatUtils = require('../formatUtils')
Expand Down Expand Up @@ -28,9 +28,12 @@ exports.tag = tag
function formatDate (date) {
// Always format in UTC. The local timezone shouldn't be used since it's most
// likely different from that of CI servers.
const utc = moment.utc(date)
const ms = utc.milliseconds()
return utc.format(`YYYY-MM-DD HH:mm:ss [${ms > 0 ? `${ms}ms Z` : 'Z'}]`)
return dateTime({
date,
local: false,
showTimeZone: true,
showMilliseconds: true
})
}

class DateValue extends object.ObjectValue {
Expand Down
15 changes: 10 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
},
"homepage": "https://github.com/concordancejs/concordance#readme",
"dependencies": {
"date-time": "^2.1.0",
"esutils": "^2.0.2",
"fast-diff": "^1.1.1",
"function-name-support": "^0.2.0",
Expand All @@ -35,7 +36,6 @@
"lodash.flattendeep": "^4.4.0",
"lodash.merge": "^4.6.0",
"md5-hex": "^2.0.0",
"moment": "^2.18.1",
"semver": "^5.3.0",
"well-known-symbols": "^1.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions test/snapshots/diff.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,8 @@ Generated by [AVA](https://ava.li).

> Snapshot 1
`%diffGutters.actual#- %%object.ctor.open%Date%object.ctor.close% %date.value.open%1969-07-20 20:17:40 Z%date.value.close% %object.openBracket#{%%object.closeBracket#}%␊
%diffGutters.expected#+ %%object.ctor.open%Date%object.ctor.close% %date.value.open%1969-07-21 20:17:40 Z%date.value.close% %object.openBracket#{%␊
`%diffGutters.actual#- %%object.ctor.open%Date%object.ctor.close% %date.value.open%1969-07-20 20:17:40 UTC%date.value.close% %object.openBracket#{%%object.closeBracket#}%␊
%diffGutters.expected#+ %%object.ctor.open%Date%object.ctor.close% %date.value.open%1969-07-21 20:17:40 UTC%date.value.close% %object.openBracket#{%␊
%diffGutters.expected#+ % foo%property.separator#: %%string.line.open#'%%string.open%bar%string.close%%string.line.close#'%%property.after#,%␊
%diffGutters.expected#+ %%object.closeBracket#}%`

Expand Down
Binary file modified test/snapshots/diff.js.snap
Binary file not shown.
6 changes: 3 additions & 3 deletions test/snapshots/format.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ Generated by [AVA](https://ava.li).

> Snapshot 1
'%object.ctor.open%Date%object.ctor.close% %date.value.open%1969-07-20 20:17:40 12ms Z%date.value.close% %object.openBracket#{%%object.closeBracket#}%'
'%object.ctor.open%Date%object.ctor.close% %date.value.open%1969-07-20 20:17:40 12ms UTC%date.value.close% %object.openBracket#{%%object.closeBracket#}%'

> Snapshot 2
Expand All @@ -473,7 +473,7 @@ Generated by [AVA](https://ava.li).

> Snapshot 1
`%object.ctor.open%Date%object.ctor.close% %date.value.open%1969-07-20 20:17:40 Z%date.value.close% %object.openBracket#{%␊
`%object.ctor.open%Date%object.ctor.close% %date.value.open%1969-07-20 20:17:40 UTC%date.value.close% %object.openBracket#{%␊
foo%property.separator#: %%string.line.open#'%%string.open%bar%string.close%%string.line.close#'%%property.after#,%␊
%object.closeBracket#}%`

Expand Down Expand Up @@ -813,7 +813,7 @@ Generated by [AVA](https://ava.li).

> Snapshot 3
'%object.ctor.open%Baz%object.ctor.close% %object.secondaryStringTag.open#@%Date%object.secondaryStringTag.close% %date.value.open%1969-07-20 20:17:40 Z%date.value.close% %object.openBracket#{%%object.closeBracket#}%'
'%object.ctor.open%Baz%object.ctor.close% %object.secondaryStringTag.open#@%Date%object.secondaryStringTag.close% %date.value.open%1969-07-20 20:17:40 UTC%date.value.close% %object.openBracket#{%%object.closeBracket#}%'

> Snapshot 4
Expand Down
Binary file modified test/snapshots/format.js.snap
Binary file not shown.
8 changes: 4 additions & 4 deletions test/snapshots/max-depth.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Generated by [AVA](https://ava.li).
two: {␊
arr: [],␊
arr2: Array [ … ],␊
date: Date 1969-07-20 20:17:40 Z {},␊
date2: Date 1969-07-20 20:17:40 Z { … },␊
date: Date 1969-07-20 20:17:40 UTC {},␊
date2: Date 1969-07-20 20:17:40 UTC { … },␊
error: Error { … },␊
fn: Function fn {},␊
fn2: Function { … },␊
Expand Down Expand Up @@ -71,8 +71,8 @@ Generated by [AVA](https://ava.li).
two: {␊
arr: [],␊
arr2: Array [ … ],␊
date: Date 1969-07-20 20:17:40 Z {},␊
date2: Date 1969-07-20 20:17:40 Z { … },␊
date: Date 1969-07-20 20:17:40 UTC {},␊
date2: Date 1969-07-20 20:17:40 UTC { … },␊
error: Error { … },␊
fn: Function fn {},␊
fn2: Function { … },␊
Expand Down
Binary file modified test/snapshots/max-depth.js.snap
Binary file not shown.

0 comments on commit 611e720

Please sign in to comment.