GithubHelp home page GithubHelp logo

Comments (4)

kylekatarnls avatar kylekatarnls commented on May 18, 2024

First of all the result "2019-06-10 00:00:00.000000" is correct, because "2019-06-06 19:02:00" is Thursday and so open, it does not close until Saturday 00:00 (since it's continuously open from Monday to Friday included), and re-open on Monday 00:00 (the next open "2019-06-10 00:00:00.000000"). Why would you expect an other result?

Then 23:59 is different from 24:00 because it means it's closed 1 minute each night.

I will fix the infinite loop bug. But unless you can explain why it's incorrect, the outputs will not change.

from opening-hours.

kylekatarnls avatar kylekatarnls commented on May 18, 2024

In fact the infinite loop is not a bug neither but a rather a not supported case. As it's continuously open every day, we cannot find the next close and so the next open neither, and we iterate until infinity. As you could pass exceptions, for example '2035-05-12' => ['00:00-02:00'] it justifies we continue to search for the possible next open.

Maybe we could detect if there are exceptions in the future and else, stop iterating after a week, then return null or throwing an exception.

from opening-hours.

kylekatarnls avatar kylekatarnls commented on May 18, 2024

The patch 2.3.1 introduces a iteration limit (8 days if there is no exceptions, 366 days else) and this limit can be customized with ->setDayLimit()

I close this issue as for me there are 2 different and not related subjects here. I consider the infinite loop as fixed.

About the fact you expect the same result using "24:00" or "23;59" I can't be agree, opening-hours is minute-precise so 24:00 = 00:00 on next day, while 23:59 is 1 minute before.

If you still think, we should handle it differently or if you find inconsistencies in outputs, please open an other issue with what you expect and why, and maybe a real use-case for it because exemples of ever closed/ever open would not make too much sense according to the purpose of this library

from opening-hours.

ahouston avatar ahouston commented on May 18, 2024

Hi Kyle, thanks for the detailed feedback.

I understand your reasoning with the 24:00 vs 23:59 - I'll modify my code to work with that. I'm probably using this outside of your intended use-case as I'm using it to process alert schedules for an event system, so "always open" or 24x7x365 is one of the possible schedules that would probably not be usual for a business!

Thanks for the 2.3.1 patch, much appreciated!

from opening-hours.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.