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

Change daily tasks get_due to use server's isDue property #5

Open
goldfndr opened this issue Aug 1, 2016 · 2 comments
Open

Change daily tasks get_due to use server's isDue property #5

goldfndr opened this issue Aug 1, 2016 · 2 comments

Comments

@goldfndr
Copy link
Owner

goldfndr commented Aug 1, 2016

Currently, the get_due function expects all daily tasks to be have frequency=weekly. That is, the days of the week (within repeat) are true/false depending on whether the task is due that particular weekday.

But, since 6/11/2015, Habitica has changed to also accept frequency=daily with an everyX value corresponding to an interval and a startDate (in ISO 8601 format) for when the every X started. Obviously, this requires new code to handle it, and converting ISO 8601 to something more usable (like seconds since epoch) is nontrivial.

The User Data Display Tool handles this by including:
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.3/moment.min.js"></script>
and using Moment.js to check the date for due-ness.

It would be preferable to handle this by on-demand loading if possible, as only the get_due function would use this functionality and it would be slightly cumbersome to require moment.js (or moment.min.js) be specified in the JavaScript action as a Library (and that's assuming that loading it as a library would even work).

@goldfndr
Copy link
Owner Author

goldfndr commented Aug 1, 2016

In addition to get_due, the get_tasks_by_tag_name function uses similar code to check whether a daily is due today and would need to be similarly improved.

@goldfndr
Copy link
Owner Author

goldfndr commented Sep 15, 2018

No later than version 8.6 (15 months ago) of the UDDT, Habitica has created an isDue property for dailies that can be checked. It'd be preferable to use this property from the server instead of performing the calculations on the client.

Even if Moment.js was required, Day.js looks like a good lightweight alternative.

@goldfndr goldfndr changed the title Handle a daily task's frequency=daily Change daily tasks get_due to use server's isDue property Sep 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant