diff options
| author | Russ Cox <rsc@golang.org> | 2014-03-24 20:34:17 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2014-03-24 20:34:17 -0400 |
| commit | 3b27343c14fdfeaa19b20b26ce660aafa814d01d (patch) | |
| tree | e6f135d7c009dae736a7064ad26532ca6a5996db /src | |
| parent | a9014ba4150b782ee10ab532752f97a7df26846e (diff) | |
| download | go-3b27343c14fdfeaa19b20b26ce660aafa814d01d.tar.xz | |
time: add comment explaining rejection of years outside [0000,9999]
This has come up twice now. Redirect future questions
to the explanation in the issue tracker.
LGTM=iant, r
R=r, iant
CC=golang-codereviews
https://golang.org/cl/79550043
Diffstat (limited to 'src')
| -rw-r--r-- | src/pkg/time/time.go | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/pkg/time/time.go b/src/pkg/time/time.go index c504df7401..0a2b091428 100644 --- a/src/pkg/time/time.go +++ b/src/pkg/time/time.go @@ -934,6 +934,8 @@ func (t *Time) GobDecode(data []byte) error { // The time is a quoted string in RFC 3339 format, with sub-second precision added if present. func (t Time) MarshalJSON() ([]byte, error) { if y := t.Year(); y < 0 || y >= 10000 { + // RFC 3339 is clear that years are 4 digits exactly. + // See golang.org/issue/4556#c15 for more discussion. return nil, errors.New("Time.MarshalJSON: year outside of range [0,9999]") } return []byte(t.Format(`"` + RFC3339Nano + `"`)), nil |
