florianv / business

:date: DateTime calculations in business hours
http://florianv.github.io/business
MIT License
361 stars 25 forks source link

Get closest nth business day #7

Closed sagikazarmark closed 9 years ago

sagikazarmark commented 9 years ago

Currently it is possible to calculate nth business day with subsequent calls to the closest method. I wonder if there is a better way internally.

Use case: depending on order date and shipping carrier, shipping date can vary. For example carrier one ships within two business days and so on.

florianv commented 9 years ago

For information the closest() is optimized, it performs a translation to the next opening date instead of iterating on all dates and seeing if it's opened.

sagikazarmark commented 9 years ago

So subsequent calls are safe from a performance point of view?

florianv commented 9 years ago

Yes, I don't see a better algorithm than the current one. The only other way is to iterate all dates but it will be slower

sagikazarmark commented 9 years ago

Well, what I wanted to confirm is that it is safe to subsequently call closest and there is no "better" way of doing this internally.

florianv commented 9 years ago

No :) I close this issue then