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

Request for API for 'next business Friday' etc #194

Open
nzifnab opened this issue Sep 18, 2019 · 0 comments
Open

Request for API for 'next business Friday' etc #194

nzifnab opened this issue Sep 18, 2019 · 0 comments

Comments

@nzifnab
Copy link

nzifnab commented Sep 18, 2019

I've come across a situation where I'd like to have a date for "The friday that follows X". So if "X" is a tuesday, I want it to be the following friday, if X is a friday, it can return X. Similar to how first_business_day will return the given day if it is a business day, otherwise the next one. If the immediately following friday isn't a workday it can return the one after that. If you've done something impossible like chosen :saturday, and no Saturdays can be work days... maybe raise an error, or return nil.

I would propose perhaps just an additional param in first_business_day, something like:

Time.first_business_day(Time.current, :friday)

Or:

Time.first_business_day(Time.current, day_of_week: :friday)

Update:

FWIW I'm just going to do it this way for now, which is "good enough" for my use-case I think:

Time.current + ((5.days-Date.current.wday.days) % 7.days)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant