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

Adds support for iso date string delay #805

Closed
wants to merge 1 commit into from

Conversation

baldurh
Copy link

@baldurh baldurh commented Jan 14, 2016

My company is working on adding a kue server for running jobs at particular dates in the future. To do that we need to be able to provide a date for the job via the JSON API. However, we quickly realized that the date is not recognized by kue. The reason for that is because the code uses lodash’s isDate method which only checks whether the value is a classified Date object. Dates are passed as strings via JSON so the check fails and the job is executed immediately.

This PR adds support for ISO formatted date strings by using moment.js

@behrad
Copy link
Collaborator

behrad commented Oct 14, 2016

I think this can be done by the caller not inside Kue

@behrad behrad closed this Oct 14, 2016
@baldurh
Copy link
Author

baldurh commented Oct 14, 2016

How would you do this in the caller? I did not find a way.
The problem is kue only checks if the ms variable is a JavaScript Date object which it will never be because it is always passed as a string via JSON.

@behrad
Copy link
Collaborator

behrad commented Oct 14, 2016

ms is the delay interval in milliseconds, First convert your point of time in ISO string to milliseconds epoch and pass the diff from now to ms

@baldurh
Copy link
Author

baldurh commented Oct 14, 2016

Well, the docs clearly suggest the .delay() method support passing a Date object so I was a bit surprised there was no way to use that functionality in the REST API. I just thought it was convenient since you already support it.

@behrad
Copy link
Collaborator

behrad commented Oct 14, 2016

.delay classically supports ms in milliseconds however passing Date objects was added recently as a user PR. Docs may not have been updated accordingly :)

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

Successfully merging this pull request may close these issues.

2 participants