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

Closed
akavel opened this issue May 25, 2018 · 5 comments
Closed

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

akavel opened this issue May 25, 2018 · 5 comments
Labels
NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. Proposal v2 A language change or incompatible library change
Milestone

Comments

@akavel
Copy link
Contributor

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

@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
@andybons andybons added the v2 A language change or incompatible library change label May 25, 2018
@ianlancetaylor
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor

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
Copy link
Contributor Author

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".)

@ianlancetaylor ianlancetaylor added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Sep 12, 2018
@ALTree ALTree removed the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Jul 1, 2019
@ianlancetaylor ianlancetaylor added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Jul 9, 2019
@gopherbot gopherbot removed the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Aug 16, 2019
@gopherbot gopherbot added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Sep 3, 2019
@ianlancetaylor
Copy link
Contributor

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.

@ianlancetaylor ianlancetaylor closed this as not planned Won't fix, can't repro, duplicate, stale Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. Proposal v2 A language change or incompatible library change
Projects
None yet
Development

No branches or pull requests

6 participants