Properly support time locales
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
"jquery": "^3.3.1",
|
||||
"lodash.debounce": "^4.0.8",
|
||||
"lodash.throttle": "^4.1.1",
|
||||
"moment": "^2.24.0",
|
||||
"moving-average": "^1.0.0",
|
||||
"number-abbreviate": "^2.0.0",
|
||||
"prismjs": "^1.15.0",
|
||||
|
||||
@@ -1,13 +1,22 @@
|
||||
import * as React from 'react'
|
||||
import * as moment from 'moment'
|
||||
|
||||
interface Props {
|
||||
date: Date
|
||||
}
|
||||
|
||||
class DateFormatter extends React.Component<Props, {}> {
|
||||
|
||||
public render() {
|
||||
return <span>{this.props.date.toLocaleDateString()} {this.props.date.toLocaleTimeString()}</span>
|
||||
const momentObject = this.localizedMoment()
|
||||
return <span>{momentObject.format('L')} {momentObject.format('LTS')}</span>
|
||||
}
|
||||
|
||||
private getLocale() {
|
||||
return window.navigator.language
|
||||
}
|
||||
|
||||
private localizedMoment() {
|
||||
return moment(this.props.date).locale(this.getLocale())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3608,7 +3608,7 @@ mkdirp@0.5.x, mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0:
|
||||
dependencies:
|
||||
minimist "0.0.8"
|
||||
|
||||
moment@>=2.13.0:
|
||||
moment@>=2.13.0, moment@^2.24.0:
|
||||
version "2.24.0"
|
||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b"
|
||||
integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==
|
||||
|
||||
Reference in New Issue
Block a user