Senior Software Engineer at Ravelin
-
Ravelin - @unravelin
- London
-
04:28
(UTC) - jamiewillis.io
Pinned Loading
-
-
-
A function for adjusting dates by mo...
A function for adjusting dates by months in Go, while maintaining the day of the month where possible. If the target month does not have enough days the last day of the month is used. 1import "time"
23func AddMonths(d time.Time, months int) time.Time {
4targetMonth := d.AddDate(0, months, 1-d.Day())
5daysInTargetMonth := targetMonth.AddDate(0, 1, -1).Day()
Something went wrong, please refresh the page to try again.
If the problem persists, check the GitHub status page or contact support.
If the problem persists, check the GitHub status page or contact support.