Skip to content

Commit

Permalink
Don't be more precise than days in messages
Browse files Browse the repository at this point in the history
  • Loading branch information
kr-matthews committed Jan 4, 2025
1 parent 02617eb commit 0fe5b23
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,18 @@ const competingStatusIcon = (competingStatus) => {
};

const registrationStatusIconText = (competition) => {
const toRelativeOptions = {
// don't be more precise than "days" (i.e. no hours/minutes/seconds)
unit: ["years", "quarters", "months", "weeks", "days"],
// round up, e.g. in 8 hours -> pads to 1 day 8 hours -> rounds to "in 1 day"
padding: 24 * 60 * 60 * 1000,
};

if (competition.registration_status === 'not_yet_opened') {
return I18n.t('competitions.index.tooltips.registration.opens_in', { duration: DateTime.fromISO(competition.registration_open).toRelative() });
return I18n.t('competitions.index.tooltips.registration.opens_in', { duration: DateTime.fromISO(competition.registration_open).toRelative(toRelativeOptions) });
}
if (competition.registration_status === 'past') {
return I18n.t('competitions.index.tooltips.registration.closed', { days: DateTime.fromISO(competition.start_date).toRelative() });
return I18n.t('competitions.index.tooltips.registration.closed', { days: DateTime.fromISO(competition.start_date).toRelative(toRelativeOptions) });
}
if (competition.registration_status === 'full') {
return I18n.t('competitions.index.tooltips.registration.full');
Expand Down

0 comments on commit 0fe5b23

Please sign in to comment.