Skip to content

Commit

Permalink
Fix moth creation
Browse files Browse the repository at this point in the history
- Fixed creation of months
- Add year to month name
  • Loading branch information
sarukuku committed Dec 23, 2019
1 parent d042404 commit 0e76624
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/routes/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ router.delete('/:id', (req, res, next) => {
const checkMonths = async (report, nMonths) => {
const { id, months } = report
let windowDate = new Date()
windowDate.setMonth(-nMonths)
windowDate.setMonth(windowDate.getMonth() - nMonths)

let indexMonthReport = 0
let indexMonthWindow = 0
Expand All @@ -59,7 +59,7 @@ const checkMonths = async (report, nMonths) => {
if (!!monthReport && windowDate.getMonth() === monthReport.date.getMonth()) {
indexMonthReport++
} else if (!monthReport || monthReport.date.getMonth() > windowDate.getMonth()) {
months.splice(indexMonthReport, 0, await createMonth(id, { name: getMonthName(windowDate.getMonth()), date: windowDate }))
months.splice(indexMonthReport, 0, await createMonth(id, { name: `${getMonthName(windowDate.getMonth())} ${windowDate.getFullYear()}`, date: windowDate }))
indexMonthReport++
}

Expand Down

0 comments on commit 0e76624

Please sign in to comment.