Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

516: Show end date on day overflow #532

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions FU.SPA/src/components/PostCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const PostCard = ({ post, showActions, onTagClick, showJoinedStatus }) => {
if (post.startTime) {
let startOfToday = dayjs().startOf('day');
let postStartDateTime = dayjs(post.startTime);
let postEndDateTime = dayjs(post.endTime);

let startDate = dayjs(post.startTime).format('MMM D, YYYY');
if (postStartDateTime < startOfToday) {
Expand All @@ -60,14 +61,34 @@ const PostCard = ({ post, showActions, onTagClick, showJoinedStatus }) => {
startDate = dayjs(post.startTime).format('MMM D');
}

let endDate = '';
if (!postEndDateTime.isSame(postStartDateTime, 'day')) {
endDate = dayjs(post.endTime).format('MMM D, YYYY');
if (postEndDateTime < startOfToday) {
// Use default
} else if (postEndDateTime < startOfToday.add(1, 'day')) {
endDate = 'Today';
} else if (postEndDateTime < startOfToday.add(2, 'day')) {
endDate = 'Tomorrow';
} else if (postEndDateTime < startOfToday.add(6, 'day')) {
endDate = dayjs(post.endTime).format('ddd');
} else if (postEndDateTime < startOfToday.add(1, 'year')) {
endDate = dayjs(post.endTime).format('MMM D');
}
}

var startTime = new Date(post.startTime).toLocaleString('en-US', {
timeStyle: 'short',
});
var endTime = new Date(post.endTime).toLocaleString('en-US', {
timeStyle: 'short',
});

dateTimeString = `${startDate}, ${startTime} - ${endTime}`;
dateTimeString = `${startDate}, ${startTime} - `;
if (endDate !== '') {
dateTimeString += `${endDate}, `;
}
dateTimeString += `${endTime}`;
} else {
dateTimeString = 'No time';
}
Expand Down Expand Up @@ -127,9 +148,11 @@ const PostCard = ({ post, showActions, onTagClick, showJoinedStatus }) => {
{post.game}
</Typography>
</Tooltip>
<Typography variant="body2" noWrap>
{dateTimeString}
</Typography>
<Tooltip title={dateTimeString}>
<Typography variant="body2" noWrap>
{dateTimeString}
</Typography>
</Tooltip>
<Divider
sx={{
borderColor: Theme.palette.primary.main,
Expand Down
Loading