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
Introduce Date#all_day #24930
Introduce Date#all_day #24930
Conversation
r? @senny (@rails-bot has picked a reviewer for you, use r? to override) |
@@ -85,6 +85,11 @@ def end_of_day | |||
end | |||
alias :at_end_of_day :end_of_day | |||
|
|||
# Returns a Range representing the whole day of the current date. |
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.
Don't love the phrasing "current date", but this is based on the docs for the Time method, which say "current time". In both cases, we mean the instance's date/time.
Wouldn't it make more sense to use just |
Oops, will look into the CI failures. @egilburg Hm, possibly. I don't mind the explicitness of the |
Useful for queries like: Item.where(created_at: Date.current.all_day) There was already a Time#all_day with the same behaviour, but for queries like the above, Date is more convenient.
Seems Senny might be unavailable – let's try this: r? |
r? @pixeltrix might be able to help out. |
@sgrif Thank you, appreciate it! |
Simplify code such as ``` Date.today.beginning_of_day..Date.today.end_of_day ``` to ``` Date.today.all_day ``` Raised by rubocop. [Introduced here](rails/rails#24930) see [this article form more](https://www.bigbinary.com/blog/rails-5-1-has-introduced-date-all_day-helper)
Useful for queries like:
There was already a
Time#all_day
with the same behaviour, so you can already dobut arguably having the method on
Date
as well makes it both read better, and more convenient to write.