Skip to content

Commit be4ca3d

Browse files
committed
Fixes cookpete#24 by using moment.js and removing unit test that uses Date.getDate() directly
1 parent b6edd20 commit be4ca3d

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"fs-extra": "^5.0.0",
4646
"handlebars": "^4.0.11",
4747
"parse-github-url": "^1.0.1",
48-
"semver": "^5.1.0"
48+
"semver": "^5.1.0",
49+
"moment": "^2.20.1"
4950
},
5051
"devDependencies": {
5152
"babel-cli": "^6.3.17",

src/utils.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { spawn } from 'child_process'
2-
3-
const MONTH_NAMES = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
2+
import moment from 'moment'
3+
//const moment = require('moment')
44

55
// Simple util for calling a child process
66
export function cmd (string) {
@@ -16,11 +16,7 @@ export function cmd (string) {
1616
}
1717

1818
export function niceDate (string) {
19-
const date = new Date(string)
20-
const day = date.getDate()
21-
const month = MONTH_NAMES[date.getMonth()]
22-
const year = date.getFullYear()
23-
return `${day} ${month} ${year}`
19+
return moment(string).format('D MMMM YYYY')
2420
}
2521

2622
export function removeIndentation (string) {

test/utils.js

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ describe('niceDate', () => {
1818

1919
it('formats date into nice date', () => {
2020
expect(niceDate(new Date(2016, 8, 2))).to.equal('2 September 2016')
21-
expect(niceDate(new Date('2015-10-03'))).to.equal('3 October 2015')
2221
})
2322
})
2423

0 commit comments

Comments
 (0)