later icon indicating copy to clipboard operation
later copied to clipboard

Removing exceptions

Open ilanbiala opened this issue 10 years ago • 9 comments

How can I remove an exception that I previously set?

ilanbiala avatar Jan 04 '15 18:01 ilanbiala

Later schedules are just JSON objects (do a console.log on your schedule to see what it looks like). To remove an exception, just find the one that you want to remove and delete it from the exception list.

bunkat avatar Jan 04 '15 21:01 bunkat

Is it possible to implement a schedule.removeException(date) to abstract this and make it part of the library? Dealing with the object itself will cause lots of issues and I'm sure others could benefit from this.

ilanbiala avatar Jan 04 '15 21:01 ilanbiala

It doesn't make sense to remove exception by passing date. Exceptions aren't dates, occurrences are.

igorhart avatar Jan 04 '15 21:01 igorhart

It either boils down to a date, a day, or a time, right?

ilanbiala avatar Jan 04 '15 22:01 ilanbiala

There are lots of different types of constraints and an exception can be made up of any combination of them. Removing them is basically just doing a filter on the exceptions array to remove the one you want, however the actual filter condition depends on what types of constraints you've used and which exceptions you want to remove. I don't see any way to abstract this in a meaningful way.

bunkat avatar Jan 04 '15 22:01 bunkat

@bunkat but just because I add an exception doesn't mean I want to keep it there. We have to be able to cleanly add and remove exceptions. If the exceptions storing is refactored in any way, would it be easier?

ilanbiala avatar Jan 04 '15 22:01 ilanbiala

One way would be to store a tag along with an exception (such as 'Fridays off') and then be able to remove exceptions using this tag. I don't have any need for this, but it wouldn't be too hard to add if you wanted to implement it for your purposes.

bunkat avatar Jan 04 '15 22:01 bunkat

@bunkat open to a PR?

ilanbiala avatar Jan 04 '15 22:01 ilanbiala

Sure, as long as it has the appropriate test cases with it.

bunkat avatar Jan 04 '15 22:01 bunkat