-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Support precision in NaiveDateTime/DateTime.utc_now #12558
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
Conversation
| If you want the current time in Unix seconds, | ||
| use `System.os_time/1` instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should say this, because you can use os_time/1 for microsecond/millisecond/nanosecond times as well, and because you can still use utc_now/1 for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a standard text we have in all utc_now functions because people often do DateTime.utc_now() |> to_unix :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aaah, gotcha!
josevalim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @viniciusmuller, I have dropped some comments.
The main idea is too not use truncate and instead generate the correct version upfront. To do this, make utc_now/2 be the "canonical function" and have utc_now/1 call utc_now/2 accordingly.
Co-authored-by: José Valim <jose.valim@gmail.com>
Co-authored-by: José Valim <jose.valim@gmail.com>
Co-authored-by: José Valim <jose.valim@gmail.com>
Co-authored-by: José Valim <jose.valim@gmail.com>
Co-authored-by: José Valim <jose.valim@gmail.com>
|
💚 💙 💜 💛 ❤️ |
since elixir-lang#12558 it is also being called with :native as the time_unit
since #12558 it is also being called with :native as the time_unit
This pull request adds support for passing a time unit to
NaiveDateTimeandDateTime'sutc_now/1and creates an alternativeutc_now/2that accepts both a custom time unit and calendar.Closes #12557