Skip to content

Commit 7b273ee

Browse files
committed
Fix timelimit rendering
1 parent a07804e commit 7b273ee

File tree

3 files changed

+51
-33
lines changed

3 files changed

+51
-33
lines changed

src/components/CutoffTimeLimitPanel/CutoffTimeLimitPanel.tsx

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,34 +42,49 @@ export function CutoffTimeLimitPanel({
4242
</span>
4343
)}
4444

45-
{timeLimit && timeLimit?.cumulativeRoundIds.length > 0 && (
46-
<div className="px-2">
47-
<Trans
48-
i18nKey={'common.wca.cumulativeTimelimit'}
49-
values={{ time: timelimitTime }}
50-
components={{ b: <span className="font-semibold" /> }}
51-
/>
52-
{': '}
53-
<span>
54-
{timeLimit.cumulativeRoundIds
55-
.filter((activityCode) => activityCode !== round.id)
56-
.map((activityCode, i, arry) => {
57-
const { eventId, roundNumber } = parseActivityCode(activityCode);
58-
return (
59-
<Link
60-
key={activityCode}
61-
to={`/competitions/${wcif?.id}/events/${activityCode}`}>
62-
<span
63-
className={`cubing-icon event-${eventId} mx-1 before:-ml-1 before:mr-2`}>
64-
{t('common.activityCodeToName.round', { roundNumber })}
65-
{i < arry.length - 1 ? ', ' : ''}
66-
</span>
67-
</Link>
68-
);
69-
})}
45+
{timeLimit &&
46+
timeLimit?.cumulativeRoundIds.length > 0 &&
47+
timeLimit.cumulativeRoundIds.filter((activityCode) => activityCode !== round.id)
48+
.length === 0 && (
49+
<span className="px-2">
50+
<Trans
51+
i18nKey={'common.wca.cumulativeTimelimit'}
52+
values={{ time: timelimitTime }}
53+
components={{ b: <span className="font-semibold" /> }}
54+
/>
7055
</span>
71-
</div>
72-
)}
56+
)}
57+
58+
{timeLimit &&
59+
timeLimit?.cumulativeRoundIds.length > 0 &&
60+
timeLimit.cumulativeRoundIds.filter((activityCode) => activityCode !== round.id)
61+
.length > 0 && (
62+
<div className="px-2">
63+
<span>
64+
<Trans
65+
i18nKey={'common.wca.cumulativeTimelimitWithrounds'}
66+
values={{ time: timelimitTime }}
67+
components={{ b: <span className="font-semibold" /> }}
68+
/>
69+
{timeLimit.cumulativeRoundIds
70+
.filter((activityCode) => activityCode !== round.id)
71+
.map((activityCode, i, arry) => {
72+
const { eventId, roundNumber } = parseActivityCode(activityCode);
73+
return (
74+
<Link
75+
key={activityCode}
76+
to={`/competitions/${wcif?.id}/events/${activityCode}`}>
77+
<span
78+
className={`cubing-icon event-${eventId} mx-1 before:-ml-1 before:mr-2`}>
79+
{t('common.activityCodeToName.round', { roundNumber })}
80+
{i < arry.length - 1 ? ', ' : ''}
81+
</span>
82+
</Link>
83+
);
84+
})}
85+
</span>
86+
</div>
87+
)}
7388
</div>
7489
{round.advancementCondition && (
7590
<div>

src/i18n/en/translation.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ common:
2828
'other-mbld': 'MBLD Submission'
2929
timeLimit: 'Time Limit'
3030
cutoff: 'Cutoff'
31-
cumulativeTimelimit: Time Limit <b>{{time}}</b> with rounds
31+
cumulativeTimelimit: 'Time Limit: <b>{{time}} Cumulative</b>'
32+
cumulativeTimelimitWithrounds: 'Time Limit: <b>{{time}} Total</b> with: '
3233
advancement:
3334
ranking: 'Top <b>{{level}}</b> to next round'
3435
percent: 'Top <b>{{level}}%</b> to next round'

src/lib/results.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,17 @@ export const renderCutoff = (cutoff: Cutoff) => {
2929
return '-';
3030
}
3131

32-
return `${formatCentiseconds(cutoff.attemptResult).replace(/\.00+$/, '')}`;
32+
return `${formatCentiseconds(cutoff.attemptResult)}`;
3333
};
3434

3535
export const renderCentiseconds = (centiseconds: number) => {
36-
if (centiseconds >= 60000) {
36+
if (centiseconds >= 360000) {
3737
const hours = Math.floor(centiseconds / 360000);
38-
const centi = formatCentiseconds(centiseconds - hours * 360000).replace(/\.00+$/, '');
39-
return hours ? `${hours}:${centi}` : centi;
38+
const minutes = Math.floor((centiseconds % 360000) / 6000);
39+
const seconds = Math.floor((centiseconds % 6000) / 100);
40+
const centis = centiseconds % 100;
41+
return `${hours}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}.${centis.toString().padStart(2, '0')}`;
4042
}
4143

42-
return formatCentiseconds(centiseconds).replace(/\.00+$/, '');
44+
return formatCentiseconds(centiseconds);
4345
};

0 commit comments

Comments
 (0)