remove 'show both' date option in DateTime

This commit is contained in:
Sean Yesmunt 2020-07-09 12:55:40 -04:00
parent 706c4afd04
commit 951d7bbb63

View file

@ -12,7 +12,6 @@ type Props = {
class DateTime extends React.PureComponent<Props> { class DateTime extends React.PureComponent<Props> {
static SHOW_DATE = 'date'; static SHOW_DATE = 'date';
static SHOW_TIME = 'time'; static SHOW_TIME = 'time';
static SHOW_BOTH = 'both';
static getTimeAgoStr(date: any) { static getTimeAgoStr(date: any) {
const suffixList = ['years', 'months', 'days', 'hours', 'minutes', 'seconds', '']; const suffixList = ['years', 'months', 'days', 'hours', 'minutes', 'seconds', ''];
@ -41,8 +40,7 @@ class DateTime extends React.PureComponent<Props> {
} }
render() { render() {
const { date, timeAgo } = this.props; const { date, timeAgo, show } = this.props;
const show = this.props.show || DateTime.SHOW_BOTH;
if (timeAgo) { if (timeAgo) {
if (!date) { if (!date) {
@ -54,9 +52,8 @@ class DateTime extends React.PureComponent<Props> {
return ( return (
<span> <span>
{date && (show === DateTime.SHOW_BOTH || show === DateTime.SHOW_DATE) && moment(date).format('MMMM Do, YYYY')} {date && show === DateTime.SHOW_DATE && moment(date).format('MMMM Do, YYYY')}
{show === DateTime.SHOW_BOTH && ' '} {date && show === DateTime.SHOW_TIME && moment(date).format('hh:mm A')}
{date && (show === DateTime.SHOW_BOTH || show === DateTime.SHOW_TIME) && date.toLocaleTimeString()}
{!date && '...'} {!date && '...'}
</span> </span>
); );