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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function nextEvent doesn't work properly #130

Open
sarnakov opened this issue Nov 5, 2022 · 0 comments
Open

function nextEvent doesn't work properly #130

sarnakov opened this issue Nov 5, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@sarnakov
Copy link

sarnakov commented Nov 5, 2022

Bug description
I was using the scheduler in Impress and got unexpected behavior. I hope I get the idea right: when function nextEvent returns 0, the task must run immediately. So here we got some Task contract examples in the documentation that runs immediately or doesn't run at all.

For example:

const every = "Apr 1st";
const parsedEvery = metautil.parseEvery(every); // { YY: -1, MM: 4, DD: 1, wd: -1, hh: -1, mm: -1, ms: -1 }
const nextEvent = metautil.nextEvent(parsedEvery); // 0

So I expect, that if it's for example October 2022, the nextEvent would return duration in ms to the 1st day of April 2023.
Instead, it returns: 0

The same thing with other examples: "Sun 17:", "20th 17:15", "Apr Sun :30", "2nd :30", "Sun 3rd 00:", "Sun 5h 30m"

"15th 100s" nextEvent function returns -1, so when you use the scheduler, it doesn't run the task immediately, it simply never schedules the event.

So almost every example is not working.

Some metatests

[
      [
        { YY: -1, MM: -1, DD: -1, wd: -1, hh: 13, mm: 0, ms: -1 },
        new Date('Tue, 20 Jul 2021 12:00:00 GMT'),
        60 * 60 * 1000,
      ],
      [
        { YY: -1, MM: -1, DD: 21, wd: -1, hh: 13, mm: 0, ms: -1 },
        new Date('Tue, 20 Jul 2021 12:00:00 GMT'),
        25 * 60 * 60 * 1000,
      ]
]

I'd like to create a PR with fixing the behavior and adding proper tests if it's okay.

@sarnakov sarnakov added the bug Something isn't working label Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant