dmfs / lib-recur

A recurrence processor for Java
Apache License 2.0
199 stars 47 forks source link

Interval not set if it is one #95

Open Shreyas775 opened 3 years ago

Shreyas775 commented 3 years ago

Hi team, I am using lib recur. It generates rrule but removes interval if it is one. In the code part I see that one is default for interval so we remove it. But for my case I want to set an interval even if it is one. Is there any way we can set an interval even if it is one?

dmfs commented 3 years ago

May I ask what your use case is? Why is it important to you to add INTERVAL=1 even though that's the default?

At present there is no way to add INTERVAL=1. You could use a hack like this

public static String toString(RecurrenceRule rule) {
 return rule.getInterval() == 1 ? `rrule.toString() + ";INTERVAL=1"` : rrule.toString();
}

But that's really a hack and not a sound solution and it would break if (for whatever reason) the library adds INTERVAL=1 in a future version.

Shreyas775 commented 3 years ago

My use case is that. We call api from server in which rrule contains interval even it is one. But in local rrule dont contain interval. Because of this difference between remote and local the recyclerview (diffutils)will redraw views which is an extra process. If both are same the recyclerview(diffutils) won't redraw.

On Fri, 19 Mar 2021, 15:23 Marten Gajda, @.***> wrote:

May I ask what your use case is? Why is it important to you to add INTERVAL=1 even though that's the default?

At present there is no way to add INTERVAL=1. You could use a hack like this

public static String toString(RecurrenceRule rule) { return rule.getInterval() == 1 ? rrule.toString() + ";INTERVAL=1" : rrule.toString(); }

But that's really a hack and not a sound solution and it would break if (for whatever reason) the library adds INTERVAL=1 in a future version.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dmfs/lib-recur/issues/95#issuecomment-802701000, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQNXXHYBUVENO32KB7OXYYDTEMNKJANCNFSM4ZOA4LIQ .

dmfs commented 3 years ago

So you're using the result of toString() to compare the local and remote rrules? Is that correct? I see the issue. Do you parse the RRule on the local side or do you create with from the individual parts?