-
Notifications
You must be signed in to change notification settings - Fork 216
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
initiate business_time instead of global definitions #181
Comments
I have need for this as well. Or a way to set config parameters per calculation, e.g. 1.business_day.after(time, beginning_of_workday: '9 am', end_of_workday: '5 pm') I have the same situation as @fluxsaas where in some cases I need to use one set of config values and in another situation I need another. The solution I have at the moment is whenever I need something other than my default config I update original_beginning = BusinessTime::Config.beginning_of_workday
original_end = BusinessTime::Config.end_of_workday
BusinessTime::Config.beginning_of_workday = '9 am'
BusinessTime::Config.end_of_workday = '5 pm'
1.business_day.after(time)
BusinessTime::Config.beginning_of_workday = original_beginning
BusinessTime::Config.end_of_workday = original_end However I'm running this in a multi-threaded environment (sidekiq), and this approach is not thread safe. I just tracked down an issue where the setting in one thread was inadvertently used for the calculation in another thread. |
I agree this is an interesting use case, but its not at all what this gem was meant to solve. As the docs say, this was meant to solve a particular business problem, does that well, and is pretty feature complete. There are other date time libraries that may suit you, or you're free to take this code as an 80% solution and work up your own. |
Hey!
would it make sense to allow instantiating a buisness_time with configs e.g.
this would help me in cases where you have to change the configs for specific use cases. (e.g. a specific user in the the app has specific holidays based on country)
The text was updated successfully, but these errors were encountered: