fix: update attendance month handling to use lastMonths and correct month indexing
This commit is contained in:
@@ -253,6 +253,23 @@ function calculateMonthFromDay(startDay, days) {
|
||||
}
|
||||
}
|
||||
|
||||
function getLastMonthsWithYear(count) {
|
||||
const result = []
|
||||
const today = new Date()
|
||||
let year = today.getFullYear()
|
||||
let month = today.getMonth() // 0-11
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
result.push({ year: year, month: month + 1 })
|
||||
month--
|
||||
if (month < 0) {
|
||||
month = 11
|
||||
year--
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
export default {
|
||||
getDayOfWeek,
|
||||
extractTimeFromDateString,
|
||||
@@ -267,4 +284,5 @@ export default {
|
||||
getMonthNumber,
|
||||
getMonthName,
|
||||
daysOfWeek,
|
||||
getLastMonthsWithYear,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user