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: MarshalJSON() throws error on negative years #7566

Closed
gopherbot opened this issue Mar 17, 2014 · 2 comments
Closed

time: MarshalJSON() throws error on negative years #7566

gopherbot opened this issue Mar 17, 2014 · 2 comments
Milestone

Comments

@gopherbot
Copy link

by verdverm:

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.
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added repo-main, release-go1.3.

@rsc
Copy link
Contributor

rsc commented Mar 24, 2014

Comment 2:

Status changed to Duplicate.

Merged into issue #4556.

@rsc rsc added this to the Go1.3 milestone Apr 14, 2015
@rsc rsc removed the release-go1.3 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants