Skip to content

Commit f460851

Browse files
author
Jay Patrick Cano
committed
fix: format time to be easily readable in stats dashboard
1 parent e02c704 commit f460851

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

app/components/dashboard/Stats.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ export default function Stats() {
9191
return <i className={`devicon-${lang.toLowerCase()}-plain colored`} />;
9292
};
9393

94-
const totalHours = (stats.total_seconds / 3600).toFixed(1);
95-
const avgDaily = stats.daily_average
96-
? (stats.daily_average / 3600).toFixed(1)
97-
: (stats.total_seconds / 3600 / 7).toFixed(1);
94+
const totalHoursFormatted = formatHours(stats.total_seconds);
95+
const avgDailyFormatted = stats.daily_average
96+
? formatHours(stats.daily_average)
97+
: formatHours(stats.total_seconds / 7);
9898
const topLang = stats.languages[0]?.name || "N/A";
9999
const topEditor = stats.editors[0]?.name || "N/A";
100100
const maxLangSeconds = stats.languages[0]?.total_seconds || 1;
@@ -119,15 +119,15 @@ export default function Stats() {
119119
const statCards = [
120120
{
121121
label: "Total Coding",
122-
value: `${totalHours}h`,
122+
value: totalHoursFormatted,
123123
sub: "Last 7 days",
124124
color: "#6366f1",
125125
trend: "+12%",
126126
trendUp: true,
127127
},
128128
{
129129
label: "Daily Average",
130-
value: `${avgDaily}h`,
130+
value: avgDailyFormatted,
131131
sub: "Per day",
132132
color: "#8b5cf6",
133133
trend: "+5%",
@@ -372,7 +372,7 @@ export default function Stats() {
372372
border: "1px solid rgba(99,102,241,0.2)",
373373
borderRadius: "8px",
374374
}}
375-
formatter={(value) => [`${value as number}h`, "Time"]}
375+
formatter={(value) => [formatHours(value as number), "Time"]}
376376
/>
377377
</PieChart>
378378
</ResponsiveContainer>

0 commit comments

Comments
 (0)