3 ms·
in a SPECIFIC month. it's only 28 for february, and then only sometimes. it's only going to affect months where the month contains more days than the month aft
by steanne 3y ago
in a SPECIFIC month. it's only 28 for february, and then only sometimes. it's only going to affect months where the month contains more days than the month after it. january, march, may, august, and october.
of those, however, there's more than one date in january which would error, so the total is more than 5. 6 or 7 depending on if it's a leap year
- torstenvl 3y agoThe bug occurs when using setMonth() to a month value containing fewer days than the current date. There is no limitation in setMonth() such that you can only set the month to "the month after." I'm sorry, but I think you misunderstand this bug.
- Izkata 3y agoI think you did too, I don't have the slightest clue where your math came from. This bug happens when the month you're setting it to has fewer days than the month in the date object, so it rolls the day forward into the next month. It's the same functionality that lets you just add days and iterate over the whole year.
- torstenvl 3y agoIn non-leap years, there are potential invalid target months when the current date is January 29th, January 30th, January 31st, March 29th, March 30th, March 31st, April 29th, April 30th, May 29th, May 30th, May 31st, June 29th, June 30th, July 29th, July 30th, July 31st, August 29th, August 30th, August 31st, September 29th, September 30th, October 29th, October 30th, October 31st, November 29th, November 30th, December 29th, December 30th, or December 31st. That is, the number of days of a given year where this bug applies are: 3 in January, 3 in March, 2 in April, 3 in May, 2 in June, 3 in July, 3 in August, 2 in September, 3 in October, 2 in November, and 3 in December. 3+3+2+3+2+3+3+2+3+2+3