mirror of
https://github.com/PGYER/codefever.git
synced 2026-07-01 01:14:18 +08:00
fix(FormattedTime): use 24-hour based time for relative time (github #206)
This commit is contained in:
@@ -16,8 +16,20 @@ import localeEN from 'date-fns/locale/en-US'
|
||||
class FormattedTime extends Component {
|
||||
render () {
|
||||
let { currentLanguage, timestamp, absolute, relative } = this.props
|
||||
const localObject = currentLanguage === 'zh-cn' ? localeCN : localeEN
|
||||
let localObject = currentLanguage === 'zh-cn' ? localeCN : localeEN
|
||||
|
||||
const originFormatRelative = localObject.formatRelative
|
||||
localObject = {
|
||||
...localObject,
|
||||
formatRelative: (token, _date, _baseDate, _options) => {
|
||||
const formatString = originFormatRelative(token, _date, _baseDate, _options)
|
||||
if (typeof formatString === 'string') {
|
||||
return formatString.replace('p', 'H:mm')
|
||||
}
|
||||
return formatString
|
||||
}
|
||||
}
|
||||
|
||||
// 31536000000 = Date('1971/01/01')
|
||||
timestamp *= timestamp < 31536E6 ? 1E3 : 1
|
||||
const current = (new Date()).getTime()
|
||||
|
||||
Reference in New Issue
Block a user