Skip to content

Commit

Permalink
Merge pull request #11252 from brave/ksmith-rewards-progress-range
Browse files Browse the repository at this point in the history
Correct month-end date for rewards NTP widget
  • Loading branch information
zenparsing authored Nov 24, 2021
2 parents fdd944d + 04f24cf commit f1dc731
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ const monthDayFormatter = new Intl.DateTimeFormat(undefined, {
function renderDateRange () {
const now = new Date()
const start = new Date(now.getFullYear(), now.getMonth(), 1)
const end = new Date(start.getFullYear(), start.getMonth() + 1, -1)

// To get the last day of the month, we can create a date for the next month,
// (months greater than 11 wrap around) with the day part set to 0 (one before
// the first day of the month). The Date constructor will perform the offset
// for us.
const end = new Date(start.getFullYear(), start.getMonth() + 1, 0)

return (
<>{monthDayFormatter.format(start)} - {monthDayFormatter.format(end)}</>
)
Expand Down

0 comments on commit f1dc731

Please sign in to comment.