Fix beyond to date range formatting

This commit is contained in:
Lim Chee Aun 2024-03-22 09:33:32 +08:00
parent 5695b3ca1e
commit f6c2097a89

View file

@ -956,10 +956,12 @@ function Catchup() {
<Link to={`/catchup?id=${pc.id}`}> <Link to={`/catchup?id=${pc.id}`}>
<Icon icon="history2" />{' '} <Icon icon="history2" />{' '}
<span> <span>
{formatRange( {pc.startAt
new Date(pc.startAt), ? dtf.formatRange(
new Date(pc.endAt), new Date(pc.startAt),
)} new Date(pc.endAt),
)
: `… – ${dtf.format(new Date(pc.endAt))}`}
</span> </span>
</Link>{' '} </Link>{' '}
<span> <span>
@ -1011,7 +1013,7 @@ function Catchup() {
{posts.length > 0 && ( {posts.length > 0 && (
<p> <p>
<b class="ib"> <b class="ib">
{formatRange( {dtf.formatRange(
new Date(posts[0].createdAt), new Date(posts[0].createdAt),
new Date(posts[posts.length - 1].createdAt), new Date(posts[posts.length - 1].createdAt),
)} )}
@ -1836,9 +1838,6 @@ const dtf = new Intl.DateTimeFormat(locale, {
hour: 'numeric', hour: 'numeric',
minute: 'numeric', minute: 'numeric',
}); });
function formatRange(startDate, endDate) {
return dtf.formatRange(startDate, endDate);
}
function binByTime(data, key, numBins) { function binByTime(data, key, numBins) {
// Extract dates from data objects // Extract dates from data objects