We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 00fb7c1 commit 9647761Copy full SHA for 9647761
components/SponsoredFeedsTableWithData.tsx
@@ -42,13 +42,10 @@ const formatTimeUnit = (seconds: number): { value: number; unit: string } => {
42
durationObj = { seconds };
43
}
44
45
- const formatted = duration.format(durationObj);
46
- const match = formatted.match(/^([0-9]+)\s*(.*)$/);
47
- if (match) {
48
- return {
49
- value: parseInt(match[1], 10),
50
- unit: match[2].replace(/[0-9]/g, ""), // Remove any numbers from the unit
51
- };
+ const parts = duration.formatToParts(durationObj);
+ const intPart = parts.find((p: any) => p.type === "integer");
+ if (intPart) {
+ return { value: Number(intPart.value), unit: intPart.unit };
52
} else {
53
// fallback in case formatting fails
54
return { value: seconds, unit: "second" };
0 commit comments