business_time
business_time copied to clipboard
Consecutive work- and non-working days
The project I'm working on requires us to calculate consecutive working or non-working days around a given date, e.g. called for non-working days on a Sunday (say Sept. 25, 2016) we would expect to get a period of work-free days around this date (in this case Sept. 24 and Sept. 25 - a Saturday and a Sunday). In our case, this feature is vital as it often happens that there is a public holiday right after weekend (or a week is scattered with occasional public holidays) and we needed a simple interface that would return such an array of dates. Naturally, the implementation is straightforward but still it feels that it should be part of this gem. Wondering if such a feature would be fit for this library.
@xlts I think the clavius
gem might provide the behavior you're looking for. Check out the Clavius.between
method.
@craiglittle thanks for your suggestion, however this would work if I knew the exact range of dates in which I could look for work/non-working days in the first place. In this case I'm not able to make such assumptions and I'm looking for a more general solution, hence this issue.
I'm interested in the problem you're trying to solve, but I'm not quite sure I follow what you're looking for.
Could you provide a rough sketch of the API and expected response(s)?
There's a possibility of adding the feature to clavius
(and biz
) if it makes sense.
@craiglittle I already forked business_time
and added the desired implemetation, which is what I'm using in my project; have a look: https://github.com/xlts/business_time/commit/5bdeec8e00a5991374edd52d318ed2e4c45046b1. Although business_time
is best suited to my project's other needs, I can by all means see this feature integrated within clavius
or biz
.
If you have this working in a fork, I'd love to see a pull request.
@bokmann absolutely, pull request is ready for review: https://github.com/bokmann/business_time/pull/154