Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
time: MarshalJSON() throws error on negative years #7566
go version devel +2bce43d48503 Mon Mar 17 12:07:30 2014 -0700 linux/amd64 What steps reproduce the problem? try to MarshalJSON a negative date (i.e. negative year) http://play.golang.org/p/wwfjigrteu What happened? Time.MarshalJSON throws an error from a check on the year range [0-9999] It is if statement in MarshalJSON that produces the error https://code.google.com/p/go/source/browse/src/pkg/time/time.go#936 This seems artificial, since I remember reading somewhere (which I can't find now...), that Go's date can go back as far as 4000 something BC What should have happened instead? A negative date should be produced, in accordance with RFC-3339. The play link shows that the RFC3339 format produces the correct output. I think just the check needs to be modified or removed. This is the same for MarshalText. https://code.google.com/p/go/source/browse/src/pkg/time/time.go#953 Please provide any additional information below. I figure it's about time, pardon the unintentional pun, that I give back to the Go community. So I'd like to fix the issue as well, if that's ok with you all.