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

Switching Month/Year with given Month fails on nextTimeAfter #7

Closed
foto-andreas opened this issue Jan 20, 2020 · 2 comments
Closed

Comments

@foto-andreas
Copy link

Hi,

there is a bug in the lib when cron switches to next month and a fixed month is set in the cron expression. Here are some unit tests which show the problem. Instead of switching to 00:50 the calculated time is 23:50.

    public void testSPSTriggerProblemSameMonth() {
        assertEquals(ZonedDateTime.parse("2020-01-02T00:50:00Z"),
            new CronExpression("00 50 * 1-8 1 *")
                .nextTimeAfter(ZonedDateTime.parse("2020-01-01T23:50:00Z")));
    }

    public void testSPSTriggerProblemNextMonth() {
        assertEquals(ZonedDateTime.parse("2020-02-01T00:50:00Z"),
            new CronExpression("00 50 * 1-8 2 *")
                .nextTimeAfter(ZonedDateTime.parse("2020-01-31T23:50:00Z")));
    }

    public void testSPSTriggerProblemNextYear() {
        assertEquals(ZonedDateTime.parse("2020-01-01T00:50:00Z"),
            new CronExpression("00 50 * 1-8 1 *")
                .nextTimeAfter(ZonedDateTime.parse("2019-12-31T23:50:00Z")));
    }

    public void testSPSTriggerProblemNextMonthMonthAst() {
        assertEquals(ZonedDateTime.parse("2020-02-01T00:50:00Z"),
            new CronExpression("00 50 * 1-8 * *")
                .nextTimeAfter(ZonedDateTime.parse("2020-01-31T23:50:00Z")));
    }

    public void testSPSTriggerProblemNextYearMonthAst() {
        assertEquals(ZonedDateTime.parse("2020-01-01T00:50:00Z"),
            new CronExpression("00 50 * 1-8 * *")
                .nextTimeAfter(ZonedDateTime.parse("2019-12-31T23:50:00Z")));
    }

    public void testSPSTriggerProblemNextMonthDayAst() {
        assertEquals(ZonedDateTime.parse("2020-02-01T00:50:00Z"),
            new CronExpression("00 50 * * 2 *")
                .nextTimeAfter(ZonedDateTime.parse("2020-01-31T23:50:00Z")));
    }

    public void testSPSTriggerProblemNextYearDayAst() {
        assertEquals(ZonedDateTime.parse("2020-01-01T00:50:00Z"),
            new CronExpression("00 50 * * 1 *")
                .nextTimeAfter(ZonedDateTime.parse("2019-12-31T23:50:00Z")));
    }

    public void testSPSTriggerProblemNextMonthAllAst() {
        assertEquals(ZonedDateTime.parse("2020-02-01T00:50:00Z"),
            new CronExpression("00 50 * * * *")
                .nextTimeAfter(ZonedDateTime.parse("2020-01-31T23:50:00Z")));
    }

    public void testSPSTriggerProblemNextYearAllAst() {
        assertEquals(ZonedDateTime.parse("2020-01-01T00:50:00Z"),
            new CronExpression("00 50 * * * *")
                .nextTimeAfter(ZonedDateTime.parse("2019-12-31T23:50:00Z")));
    }

The failing tests are:

testSPSTriggerProblemNextMonth
testSPSTriggerProblemNextYear
testSPSTriggerProblemNextMonthDayAst
testSPSTriggerProblemNextYearDayAst

I checked with v1.5 and v1.4.

Cheers Andreas

@foto-andreas
Copy link
Author

Hi,

are you able to reproduce the issue? Do you need further infos?

Andreas

frode-carlsen added a commit that referenced this issue Nov 5, 2020
* chore: set up sonarcloud
* chore: copied tests for issue #7 to jodatime version
* chore: moved to maven ci-friendly versions
@frode-carlsen
Copy link
Owner

Thanks for this

frode-carlsen added a commit to navikt/fp-prosesstask that referenced this issue Nov 5, 2020
frode-carlsen added a commit to navikt/fp-prosesstask that referenced this issue Nov 5, 2020
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