[Feature Request] Extend Date Object

date = Date.today tuesday = date.next_week(:tuesday)


returns the next week’s occurrence of Tuesday, relative to today(the date instance).

At times, this may not be the required result, e.g if today were a Monday, I might just need Tuesday, it would be convenient to have something like:

date = Date.today tuesday = date.next_tuesday


if date is Monday, tuesday should return tomorrow and not necessarily next week’s Tuesday as currently provided by next_week

This would be useful largely in scheduling applications

I’d be happy to submit a PR if anyone thinks this makes some sense.

Nowadays we are pretty conservative in general adding core extensions. But dates have a bunch of methods that conform a calculations API in which your proposal makes sense in my view.

Please cc me in the PR!

Hi Xavier, Just thought to follow up on the pending PR: Introduce the next_*day and prev_*day helpers for DateAndTime related Classes by andela-oakinniranye · Pull Request #25209 · rails/rails · GitHub

Haven’t gotten any updates in a while, but I’ve updated the PR