feat: fixes and formatter

This commit is contained in:
2026-01-12 16:01:32 +01:00
parent 85c6084351
commit 11e632acff
353 changed files with 23315 additions and 27361 deletions
+19 -19
View File
@@ -1,26 +1,26 @@
const normalizeDate = (input) =>
typeof input?.toDate === "function" ? input.toDate() : new Date(input);
typeof input?.toDate === 'function' ? input.toDate() : new Date(input)
const buildMonthKey = (timestamp) => {
const date = normalizeDate(timestamp);
const year = date.getUTCFullYear();
const month = String(date.getUTCMonth() + 1).padStart(2, "0");
return `${year}-${month}`;
};
const date = normalizeDate(timestamp)
const year = date.getUTCFullYear()
const month = String(date.getUTCMonth() + 1).padStart(2, '0')
return `${year}-${month}`
}
const buildPreviousMonthContext = (referenceDate) => {
const current = referenceDate ? new Date(referenceDate) : new Date();
current.setUTCHours(0, 0, 0, 0);
current.setUTCDate(1);
const current = referenceDate ? new Date(referenceDate) : new Date()
current.setUTCHours(0, 0, 0, 0)
current.setUTCDate(1)
const target = new Date(current);
target.setUTCMonth(target.getUTCMonth() - 1);
const target = new Date(current)
target.setUTCMonth(target.getUTCMonth() - 1)
const year = target.getUTCFullYear();
const monthIndex = target.getUTCMonth();
const rangeStart = new Date(Date.UTC(year, monthIndex, 1, 0, 0, 0, 0));
const rangeEnd = new Date(Date.UTC(year, monthIndex + 1, 0, 23, 59, 59, 999));
const monthKey = buildMonthKey(rangeStart);
const year = target.getUTCFullYear()
const monthIndex = target.getUTCMonth()
const rangeStart = new Date(Date.UTC(year, monthIndex, 1, 0, 0, 0, 0))
const rangeEnd = new Date(Date.UTC(year, monthIndex + 1, 0, 23, 59, 59, 999))
const monthKey = buildMonthKey(rangeStart)
return {
year,
@@ -28,10 +28,10 @@ const buildPreviousMonthContext = (referenceDate) => {
monthKey,
rangeStart,
rangeEnd,
};
};
}
}
module.exports = {
buildMonthKey,
buildPreviousMonthContext,
};
}