hopefully stop app crashes because of bad dates
https://github.com/GoogleChrome/lighthouse/issues/1056
This commit is contained in:
parent
df756b2907
commit
c1131a374b
1 changed files with 2 additions and 12 deletions
|
@ -14,16 +14,8 @@ class DateTime extends React.PureComponent<Props> {
|
||||||
static SHOW_TIME = 'time';
|
static SHOW_TIME = 'time';
|
||||||
static SHOW_BOTH = 'both';
|
static SHOW_BOTH = 'both';
|
||||||
|
|
||||||
static defaultProps = {
|
|
||||||
formatOptions: {
|
|
||||||
month: 'long',
|
|
||||||
day: 'numeric',
|
|
||||||
year: 'numeric',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { date, formatOptions, timeAgo } = this.props;
|
const { date, timeAgo } = this.props;
|
||||||
const show = this.props.show || DateTime.SHOW_BOTH;
|
const show = this.props.show || DateTime.SHOW_BOTH;
|
||||||
|
|
||||||
if (timeAgo) {
|
if (timeAgo) {
|
||||||
|
@ -32,9 +24,7 @@ class DateTime extends React.PureComponent<Props> {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span>
|
<span>
|
||||||
{date &&
|
{date && (show === DateTime.SHOW_BOTH || show === DateTime.SHOW_DATE) && moment(date).format('MMMM Do, YYYY')}
|
||||||
(show === DateTime.SHOW_BOTH || show === DateTime.SHOW_DATE) &&
|
|
||||||
date.toLocaleDateString(undefined, formatOptions)}
|
|
||||||
{show === DateTime.SHOW_BOTH && ' '}
|
{show === DateTime.SHOW_BOTH && ' '}
|
||||||
{date && (show === DateTime.SHOW_BOTH || show === DateTime.SHOW_TIME) && date.toLocaleTimeString()}
|
{date && (show === DateTime.SHOW_BOTH || show === DateTime.SHOW_TIME) && date.toLocaleTimeString()}
|
||||||
{!date && '...'}
|
{!date && '...'}
|
||||||
|
|
Loading…
Add table
Reference in a new issue