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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: scheduler.getAvailability returning incorrect values #4

Open
ninjaPixel opened this issue Nov 21, 2017 · 2 comments
Open

Bug: scheduler.getAvailability returning incorrect values #4

ninjaPixel opened this issue Nov 21, 2017 · 2 comments
Labels

Comments

@ninjaPixel
Copy link

Hi 馃枛
Thanks for sharing this great package!

I think I've spotted a bug and wanted to let you guys know. I'm using @ssense/sscheduler@1.3.2 and have noticed that when I request availability where the duration approaches (or exceeds) the number of working hours in a schedule's day, then some incorrect time slots are marked as available.

For example, if I run

const availability = scheduler.getAvailability({
      from: '2017-02-01',
      to: '2017-02-02',
      duration: (60 * 8),
      interval: 60,
      schedule: {
        weekdays: {
          from: '09:00',
          to: '17:00',
          unavailability: [
          ],
        },
      },
    });

console.log('availability: ', availability);

The output is:

availability:  { '2017-02-01': 
[ { time: '09:00', available: true, reference: null },
{ time: '10:00', available: false, reference: null },
{ time: '11:00', available: false, reference: null },
{ time: '12:00', available: false, reference: null },
{ time: '13:00', available: false, reference: null },
{ time: '14:00', available: false, reference: null },
{ time: '15:00', available: false, reference: null },
{ time: '16:00', available: true, reference: null } ] }

I expect the 16:00 time to have the property available:false.

If I up the duration even further to 23 hours, then the availabilty object marks all the time slots as available but I'd expect them to all be false.

Thanks!

ninjaPixel added a commit to ninjaPixel/node-sscheduler that referenced this issue Nov 22, 2017
@ninjaPixel
Copy link
Author

Looking into this some more, I think the bug occurs when a duration is long enough that it spans into the next day.

In the getAvailability function in Scheduler.ts, only time is compared, and not date:

if (this.isTimeAfter(timeSlotEnd, (<moment.Moment> daySchedule.to))) { ... }

I did try changing this to:

if (this.isDateTimeAfter(timeSlotEnd, (<moment.Moment> daySchedule.to))) { ... }

But it didn't work.

@quinnlangille quinnlangille changed the title scheduler.getAvailability returning incorrect values Bug: scheduler.getAvailability returning incorrect values Oct 10, 2018
@quinnlangille
Copy link
Member

Hey @ninjaPixel, thanks for reporting the bug! This repo isn't being actively maintained, but if I get some free time in the next bit I can take a look into it. Sorry for the late reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants