mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
Rename getLastUpdated() to formatDate()
This commit is contained in:
@@ -8,7 +8,7 @@ import moment from 'moment'
|
|||||||
* @param {mixed}
|
* @param {mixed}
|
||||||
* @return {string}
|
* @return {string}
|
||||||
*/
|
*/
|
||||||
export function getLastUpdated (date) {
|
export function formatDate (date) {
|
||||||
const m = moment(date)
|
const m = moment(date)
|
||||||
if (!m.isValid()) {
|
if (!m.isValid()) {
|
||||||
throw Error('Invalid argument.')
|
throw Error('Invalid argument.')
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @fileoverview Component for show updated date of the detail.
|
* @fileoverview Component for show updated date of the detail.
|
||||||
*/
|
*/
|
||||||
import React, { PropTypes } from 'react'
|
import React, { PropTypes } from 'react'
|
||||||
import { getLastUpdated } from 'browser/lib/date-formatter'
|
import { formatDate } from 'browser/lib/date-formatter'
|
||||||
import CSSModules from 'browser/lib/CSSModules'
|
import CSSModules from 'browser/lib/CSSModules'
|
||||||
import styles from './LastUpdatedString.styl'
|
import styles from './LastUpdatedString.styl'
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ const LastUpdatedString = ({ date }) => {
|
|||||||
let text = ''
|
let text = ''
|
||||||
|
|
||||||
try {
|
try {
|
||||||
text = `Last updated at ${getLastUpdated(date)}`
|
text = `Last updated at ${formatDate(date)}`
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
text = ''
|
text = ''
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
* @fileoverview Unit test for browser/lib/date-formatter.js
|
* @fileoverview Unit test for browser/lib/date-formatter.js
|
||||||
*/
|
*/
|
||||||
const test = require('ava')
|
const test = require('ava')
|
||||||
const { getLastUpdated } = require('browser/lib/date-formatter')
|
const { formatDate } = require('browser/lib/date-formatter')
|
||||||
|
|
||||||
test(t => {
|
test(t => {
|
||||||
t.throws(
|
t.throws(
|
||||||
() => getLastUpdated('invalid argument'),
|
() => formatDate('invalid argument'),
|
||||||
'Invalid argument.'
|
'Invalid argument.'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user