-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: time: use big-endian/ISO reference time #25572
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
Comments
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? |
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. |
In #20757 (comment) I suggested a |
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".) |
We could introduce new functions with a different reference string, but I don't see any feasible way that we could change the reference string used by the current functions, even in a time/v2 package. Closing this issue. |
(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:
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:
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
The text was updated successfully, but these errors were encountered: