Created
February 2, 2022 09:21
-
-
Save bnb/cfcaeb17d04d5794f592d55ce2c626fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { DateTime } = require('luxon') | |
const now = DateTime.now() | |
const currentYear = now.year | |
const lastMonth = now.minus({ months: 1 }) | |
const lastDayOfPreviousMonth = lastMonth.set({ day: lastMonth.daysInMonth }) | |
const dates = { | |
now: now.toISODate(), // make `now` usable with ISO date format | |
lastDayOfPreviousMonth: lastDayOfPreviousMonth.toISODate(), // gets the last day of the previous month | |
checkFrom: `${currentYear}-${lastDayOfPreviousMonth.month.toString().padStart(2, 0)}-01`, // yyyy-mm-dd | |
checkUntil: `${currentYear}-${lastDayOfPreviousMonth.month.toString().padStart(2, 0)}-${lastDayOfPreviousMonth.daysInMonth.toString().padStart(2, 0)}` // yyyy-mm-dd-yyyy-mm-dd | |
} | |
console.log(currentYear) | |
module.exports = dates |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment