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

Computation error in findRecurrences? #24

Closed
guger opened this issue May 26, 2019 · 6 comments
Closed

Computation error in findRecurrences? #24

guger opened this issue May 26, 2019 · 6 comments

Comments

@guger
Copy link
Contributor

guger commented May 26, 2019

Why does recurrence.findRecurrences(1558821600001, 1) return 1558821600000?

@maltaisn
Copy link
Owner

maltaisn commented May 26, 2019

What are the recurrence rules? This is probably a bug.

@guger
Copy link
Contributor Author

guger commented May 26, 2019

Just daily.

@maltaisn
Copy link
Owner

I didn't manage to reproduce your output. What was the start date of the recurrence and in what time zone?

@guger
Copy link
Contributor Author

guger commented May 27, 2019

@Test
fun testDailyRecurrences() {
    val recurrence = Recurrence(LocalDate.now().minusDays(5).atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli(), Recurrence.DAILY)

    val missedRecurrences = recurrence.findRecurrencesBetween(0, System.currentTimeMillis())

    assertThat(missedRecurrences, notNullValue())

    val nextRecurrence = recurrence.findRecurrences(System.currentTimeMillis().inc(), 1).first()

    assertThat(nextRecurrence, notNullValue())
    assertThat(missedRecurrences.size, `is`(5))
    assertNotEquals("lastRecurrence: ${missedRecurrences.last()} - nextRecurrence $nextRecurrence", missedRecurrences.last(), nextRecurrence)
}

@maltaisn
Copy link
Owner

Thanks, I fixed it.

This is actually a kind of problem I feared would happen since the library was developed with more focus on UI than on the recurrence computation system, which should actually have been done by another library made for that. But I didn't find any at the time. So I made one that's "good enough", without a lot of testing, since recurring events is often a secondary feature in apps anyway.

@guger
Copy link
Contributor Author

guger commented May 28, 2019

Well, therefore I'm testing :)

Your libs are great, I'm using all three dialogs in my app now ;D

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

No branches or pull requests

2 participants