3
I’m using Moment.js to validate some dates and used the function moment().weeksInYear()
to check which week of the year we are in.
I need to make a date forecast, after the user informs me a date, I can calculate how many weeks will pass and we add this to the function of the increment Moment moment().weeksInYear() + semanas
.
I need to manipulate the Moment so I can figure out which Friday of the week I calculate.
example:
moment().weeksInYear() // retorna semana 52
moment().weeksInYear() + semanas // retorna 54
need to use this 54
to know the exact date of Friday of the week 54
of the year.
A year does not have 54 weeks, this calculation is wrong. You want to catch the Friday of the second week of the following year. You need to check that the sum of the weeks is greater than the amount of weeks in the year, if it is, add +1 to the current year. :)
– Renan Gomes