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

[RFC] Bring back Time.now #9275

Closed
asterite opened this issue May 11, 2020 · 5 comments
Closed

[RFC] Bring back Time.now #9275

asterite opened this issue May 11, 2020 · 5 comments

Comments

@asterite
Copy link
Member

asterite commented May 11, 2020

Every time (no pun intended) I want to get the current time I write Time.now. Then after getting an error I remember we changed it to Time.local.

I think Time.now is good: when you walk down the street and ask someone "what time is it now?" and they say "3 pm", I would be surprised if that means "3 pm UTC" or any other thing than the current local time.

In Go it's called time.Now(). In Python it's called datetime.datetime.now(). In Ruby it's Time.now. In Nim it's called now().

Could we bring it back? We can keep it as an alias of local in cases where one would think local is a bit more explicit, specially when using both local and utc to make it more obvious. I know we are against aliases, but this is just a tiny one. Otherwise we can remove local, but I don't see a need for that.

@straight-shoota
Copy link
Member

For reference, previous discussions in: #5346, #7586

This proposal would be in line with #7586 (comment) f.

@j8r
Copy link
Contributor

j8r commented May 11, 2020

Time.now is confusing. Which timezone - UTC or local one?
Not having this method forces us to think to the above question.

If I ask time to someone not in my country, it will respond by precising the timezone.
That's why in the military, they use 24-hour format and precise the timezone, to remove any possible confusions.

@j8r
Copy link
Contributor

j8r commented May 11, 2020

I also prefer reading Time.local for local time, rather than Time.now for "now time" :)

@straight-shoota
Copy link
Member

Not having this method forces us to think to the above question.

That was exactly the reason for renaming Time.now to Time.local. To make it obvious that you consider what you want. Computer systems are not like people on the street which have an unanimous agreement that current time is most usefully expressed in the locally observed time zone.

Thus, adding Time.now back would counter that intention.
However, I wouldn't want to enforce an API that's hated by many users just in order to educate them.

@asterite You're only referring to methods without arguments, so I take you only mean to add the Time.now overload returning the current time, not the ones that construct a specified Time instance?

@asterite
Copy link
Member Author

Well, nevermind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants