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

Recurrence#findRecurrences(long fromDate, long toDate) #22

Closed
guger opened this issue May 12, 2019 · 1 comment
Closed

Recurrence#findRecurrences(long fromDate, long toDate) #22

guger opened this issue May 12, 2019 · 1 comment

Comments

@guger
Copy link
Contributor

guger commented May 12, 2019

Would it be possible to implement a method which computes all recurrences within two dates?

@maltaisn
Copy link
Owner

fun Recurrence.findRecurrencesBetween(startDate: Long, endDate: Long): List<Long> {
    val recurrences = mutableListOf<Long>()
    var lastDate = this.findRecurrences(startDate, 1).first()
    var repeats = 1
    while (lastDate < endDate) {
        recurrences += lastDate
        lastDate = this.findRecurrencesBasedOn(lastDate, repeats, startDate, 1).first()
        repeats++
    }
    return recurrences
}

I'll add it in next version.

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