Introduce this_week?, this_month?, and this_year? to Date/Time#55770
Introduce this_week?, this_month?, and this_year? to Date/Time#55770dhh merged 2 commits intorails:mainfrom
this_week?, this_month?, and this_year? to Date/Time#55770Conversation
|
|
||
| # Returns true if the date/time falls within the current week. | ||
| def this_week? | ||
| ::Date.current.all_week.include?(to_date) |
There was a problem hiding this comment.
I thought comparing as date made sense for these units. Unless we plan to add current_hour? too, which then it would be best to convert to_time instead.
in_this_week?, in_this_month?, and in_this_year? meth…in_this_week?, in_this_month?, and in_this_year? to Date/Time
|
A comment about a similar PR to add methods like
|
b1428e6 to
f560dbd
Compare
5d3f157 to
e2d603d
Compare
|
I prefer skipping the aliases. We already use #in_ for conversions, like #in_minutes. But #this_week? matches #today? So I'm good with this without the #in_ aliases 👍 |
…te/Time Similar to `today?`, `tomorrow?`, and `yesterday?`, these methods are useful to query time instances against the current period. ```ruby unless date.this_week? link_to "See week recap", week_recap_path(date) end ```
e2d603d to
55e9f58
Compare
|
@dhh Done. Thank you! |
in_this_week?, in_this_month?, and in_this_year? to Date/Timethis_week?, this_month?, and this_year? to Date/Time
Similar to
today?,tomorrow?, andyesterday?, these methods are useful toquery time instances against the current period.
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]