goldfndr / tasker-habitrpg

A base for interacting with Habitica via Tasker
GNU General Public License v3.0
33 stars 11 forks source link

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

Open goldfndr opened 8 years ago

goldfndr commented 8 years ago

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 commented 8 years ago

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 commented 6 years ago

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.