Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time: add 1 month can sometimes add 2 months #10401

eclivus opened this issue Apr 9, 2015 · 2 comments


None yet
4 participants
Copy link

commented Apr 9, 2015


This might not e related to Go itself, but I noticed that when incrementing a date month by month go sometimes leaps a month.

package main

import "fmt"
import "time"

func main() {
        date := time.Date(2013,time.January,31,23,59,59,0,time.UTC)
        date = date.AddDate(0,1,0)

2013-01-31 23:59:59 +0000 UTC
2013-03-03 23:59:59 +0000 UTC

Go version: go1.4.2 linux/amd64
System: Ubuntu 14.04.1


This comment has been minimized.

Copy link

commented Apr 9, 2015

Working as intended. There is no February 31, so what happens here is reasonable. The behavior is even documented in the comment for AddDate - using almost exactly this example!

@robpike robpike closed this Apr 9, 2015


This comment has been minimized.

Copy link

commented Apr 9, 2015

@mikioh mikioh changed the title Package time : add 1 month can sometimes add 2 months time: add 1 month can sometimes add 2 months Apr 9, 2015

@golang golang locked and limited conversation to collaborators Jun 25, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.