refactor(#54): Improve month string formatting for consistent sorting

This commit is contained in:
Josh Creek
2024-11-13 15:05:04 +00:00
parent d62c92e527
commit 05a50a0ce0
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ export async function load({ locals: { safeGetSession } }) {
const monthlyAggregates = transactions.reduce((acc, transaction) => {
const date = new Date(transaction.created_at);
const month = `${date.getFullYear()}-${date.getMonth() + 1}`;
const month = date.toISOString().substring(0, 7); // Returns YYYY-MM format
if (!acc[month]) acc[month] = { credits_added: 0, credits_deducted: 0 };
+1 -1
View File
@@ -19,7 +19,7 @@
const groupedTransactions = transactions.reduce((acc, transaction) => {
const date = new Date(transaction.created_at);
const month = `${date.getFullYear()}-${date.getMonth() + 1}`;
const month = date.toISOString().substring(0, 7); // Returns YYYY-MM format
if (!acc[month]) acc[month] = [];
acc[month].push(transaction);
return acc;