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

proposal: time: use big-endian/ISO reference time #25572

Open
akavel opened this issue May 25, 2018 · 4 comments
Open

proposal: time: use big-endian/ISO reference time #25572

akavel opened this issue May 25, 2018 · 4 comments

Comments

@akavel
Copy link
Contributor

@akavel akavel commented May 25, 2018

(I couldn't find an existing issue mentioning this, so I wanted to submit it for consideration for Go2, to make sure that whatever the final decision, it's at least given proper thought and not overlooked purely by accident.)

Proposal

I propose that for Go2, the "reference time" used by time.Format and time.Parse is changed to:

2001-02-03 16:05:06-0700

alias Feb 3 16:05:06 -0700 2001.

Rationale

This has the advantage of being trivial to remember for the whole world, not only U.S. residents, as well as being generally simpler in idea, following the "network order" (a.k.a. big endian), and straightforwardly corresponding to the universally (?) known international standards of RFC 3339 / ISO 8601.

The old reference time AFAIU is more or less accidental, per Rob's 2014 comment:

The choice was made by the output of the date command on my Unix
machine. I should have realized the format varies with locale. Mea
culpa. [...]

I believe Go2 is a point where this can potentially be approached, disarming somewhat the (AFAIU) main (and only?) rejection argument of "it's too late, this ship has sailed".

Alternatives

  • #9696 — "Dec 31, 23:59:05, 1999"
@akavel akavel changed the title go2 proposal: time: change reference time to big-endian go2 proposal: time: use big-endian/ISO reference time May 25, 2018
@andybons andybons changed the title go2 proposal: time: use big-endian/ISO reference time proposal: time: use big-endian/ISO reference time May 25, 2018
@gopherbot gopherbot added this to the Proposal milestone May 25, 2018
@gopherbot gopherbot added the Proposal label May 25, 2018
@andybons andybons added the Go2 label May 25, 2018
@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

@ianlancetaylor ianlancetaylor commented May 27, 2018

Is there any reliable way we could update existing code to continue working? Presumably we could do it for constant strings, but what variables? How common is that case?

@akavel

This comment has been minimized.

Copy link
Contributor Author

@akavel akavel commented May 28, 2018

One option for variables: maybe there could be an extra package (possibly not in stdlib), which would convert Go1 format to Go2 at runtime. Nontrivial usages could be automatically rewritten to use the conversion function (e.g. time.Format(oldtime.Preformat(somefmt)))

@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented May 30, 2018

Is there any reliable way we could update existing code to continue working?

In #20757 (comment) I suggested a go1time compatibility package. If we were to take that approach, go1time.Parse could use a separate format from time.Parse, although that could potentially cause confusion during the transition: given an untyped string constant, it would be difficult to tell whether it is a Go 1 format string or a Go 2 one.

@akavel

This comment has been minimized.

Copy link
Contributor Author

@akavel akavel commented May 31, 2018

Is it expected that the rewriter tool might be run on Go2 code and that it must NOP in such case? (Because if not, then IIUC any string passed to time.Format/time.Parse can be assumed "Go 1 format string".)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.