Fix scheduled live stream
This commit is contained in:
parent
350aa8240a
commit
78e7eaa689
3 changed files with 6 additions and 5 deletions
|
@ -13,8 +13,9 @@ type Props = {
|
||||||
clock24h?: boolean,
|
clock24h?: boolean,
|
||||||
date?: any,
|
date?: any,
|
||||||
minUpdateDeltaMs?: number,
|
minUpdateDeltaMs?: number,
|
||||||
type?: string,
|
showFutureDate?: boolean,
|
||||||
timeAgo?: boolean,
|
timeAgo?: boolean,
|
||||||
|
type?: string,
|
||||||
};
|
};
|
||||||
|
|
||||||
class DateTime extends React.Component<Props, State> {
|
class DateTime extends React.Component<Props, State> {
|
||||||
|
@ -58,7 +59,7 @@ class DateTime extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { clock24h, date, type, timeAgo } = this.props;
|
const { clock24h, date, showFutureDate, timeAgo, type } = this.props;
|
||||||
|
|
||||||
const clockFormat = clock24h ? 'HH:mm' : 'hh:mm A';
|
const clockFormat = clock24h ? 'HH:mm' : 'hh:mm A';
|
||||||
|
|
||||||
|
@ -69,7 +70,7 @@ class DateTime extends React.Component<Props, State> {
|
||||||
>
|
>
|
||||||
{date
|
{date
|
||||||
? timeAgo
|
? timeAgo
|
||||||
? getTimeAgoStr(date)
|
? getTimeAgoStr(date, showFutureDate)
|
||||||
: moment(date).format(type === 'date' ? 'MMMM Do, YYYY' : clockFormat)
|
: moment(date).format(type === 'date' ? 'MMMM Do, YYYY' : clockFormat)
|
||||||
: '...'}
|
: '...'}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -29,7 +29,7 @@ const LivestreamDateTime = (props: Props) => {
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<span>
|
<span>
|
||||||
{__('Live')} <DateTime timeAgo uri={uri} />
|
{__('Live')} <DateTime timeAgo uri={uri} showFutureDate />
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,7 +47,7 @@ export function getTimeAgoStr(date: any, showFutureDate?: boolean) {
|
||||||
duration = Math.floor(moment().diff(date, s));
|
duration = Math.floor(moment().diff(date, s));
|
||||||
suffix = s;
|
suffix = s;
|
||||||
|
|
||||||
return duration > 0;
|
return duration > 0 || (showFutureDate && duration * -1 > 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
// negative duration === it's a future date from now
|
// negative duration === it's a future date from now
|
||||||
|
|
Loading…
Add table
Reference in a new issue