Senior Software Engineer at Ravelin
- Ravelin -@unravelin
- London
- 08:18
(UTC) - jamiewillis.io
PinnedLoading
- 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"
23funcAddMonths(d time.Time,monthsint) 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 theGitHub status page orcontact support.
If the problem persists, check theGitHub status page orcontact support.