Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #24 by using moment.js and removing unit test that uses Date.ge… #25

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"fs-extra": "^5.0.0",
"handlebars": "^4.0.11",
"parse-github-url": "^1.0.1",
"semver": "^5.1.0"
"semver": "^5.1.0",
"moment": "^2.20.1"
},
"devDependencies": {
"babel-cli": "^6.3.17",
Expand Down
9 changes: 2 additions & 7 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { spawn } from 'child_process'

const MONTH_NAMES = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
import moment from 'moment'

// Simple util for calling a child process
export function cmd (string) {
Expand All @@ -16,11 +15,7 @@ export function cmd (string) {
}

export function niceDate (string) {
const date = new Date(string)
const day = date.getDate()
const month = MONTH_NAMES[date.getMonth()]
const year = date.getFullYear()
return `${day} ${month} ${year}`
return moment(string).format('D MMMM YYYY')
}

export function removeIndentation (string) {
Expand Down
1 change: 0 additions & 1 deletion test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ describe('niceDate', () => {

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

Expand Down