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: Add time.Day constant #56460

Closed
mohamedattahri opened this issue Oct 27, 2022 · 6 comments
Closed

proposal: time: Add time.Day constant #56460

mohamedattahri opened this issue Oct 27, 2022 · 6 comments

Comments

@mohamedattahri
Copy link
Contributor

This is a modest and self-explanatory proposal to add a time.Day constant to the time package.

To restate the obvious:

  • It's needed for the same reason all the other constants in the package exist;
  • It would improve the readability of a lot of code where the required precision for dates is a day (e.g. billing);
  • For new gophers, the omission is rather unexpected.

I personally see any downsides, and the one-liner needed seems worth it.

Github search for code mentioning "24 * time.Hour".

@gopherbot gopherbot added this to the Proposal milestone Oct 27, 2022
@ianlancetaylor
Copy link
Contributor

I feel sure that this has come up before, but I wasn't able to find an earlier issue.

We have historically rejected this because not all days are 24 hours. At a daylight savings transition there are 23 hour days and 25 hour days. While for many uses 24 * Hour is the correct value, that is not always right. By not defining Day, we force people to consider exactly what they need.

@mohamedattahri
Copy link
Contributor Author

Thanks @ianlancetaylor – I see the logic now, and I'm glad it's documented here.

If the goal is to force people to consider what they need, then I feel like it's rather ineffective way to go about it. More prosaically, I'm not sure typing 3 * 24 * time.Day instead of 3 * time.Day brings up any DST consideration in my mind, but I may be biased by only dealing with UTC.

@seankhliao
Copy link
Member

Duplicate of #11473

@seankhliao seankhliao marked this as a duplicate of #11473 Oct 27, 2022
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Oct 27, 2022
@mohamedattahri
Copy link
Contributor Author

@seankhliao – The duplicate is not open for discussion, and seems restricted to collaborators.

@ianlancetaylor
Copy link
Contributor

@seankhliao Thanks for finding the earlier issue.

@mohamedattahri Our general approach is that once we've made a decision, we don't change that decision unless there is new information that we didn't consider. If we don't follow that policy, we will be get into an endless loop of discussing older decisions, and won't have any time to make any forward progress.

So if you have new information, by all means share it here and we can reopen the issue. Otherwise, please respect that we've made a decision here even if it's different than the one that you would have made. Thanks.

@rsc
Copy link
Contributor

rsc commented Nov 9, 2022

This proposal is a duplicate of a previously discussed proposal, as noted above,
and there is no significant new information to justify reopening the discussion.
The issue has therefore been declined as a duplicate.
— rsc for the proposal review group

@golang golang locked and limited conversation to collaborators Nov 9, 2023
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

5 participants