You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you run this on the 31st of the month it won't print the beginning of the next month but the beginning of the month after
So on 03-21-2021 it'll print 05-01-201 instead of 04-01-2021
The text was updated successfully, but these errors were encountered:
In your example, AddDate(0, 1, 0) returns 05-01-2021.
This is the expected behavior. From Time.AddDate:
AddDate normalizes its result in the same way that Date does, so, for example, adding one month to October 31 yields December 1, the normalized form for November 31.
You can fix it by adding a month after finding the first day of the month. playground
Reproducible Example
https://play.golang.org/p/o21N9NbVLdk
Description
If you run this on the 31st of the month it won't print the beginning of the next month but the beginning of the month after
So on 03-21-2021 it'll print 05-01-201 instead of 04-01-2021
The text was updated successfully, but these errors were encountered: