cron-utils
cron-utils copied to clipboard
timeFromLastExecution with zoneId ignores november 3
Not sure if this problem is related to issues #402 and #403 but using zoneid "America/Sao_Paulo" with a cron starting at midnight I just can't get a correct time for today (november 3).
This is the code, I'll also submit a pull request.
final CronDefinition cronDefinition = CronDefinitionBuilder.defineCron().withMinutes().and().withHours().and()
.withDayOfWeek().and().instance();
final Cron cron = new CronParser(cronDefinition).parse("0 0 *");
final ExecutionTime executionTime = ExecutionTime.forCron(cron);
final ZonedDateTime time = LocalDateTime.of(2019, 11, 3, 0, 0, 1).atZone(ZoneId.of("America/Sao_Paulo"));
final Duration timeFromLastExecution = executionTime.timeFromLastExecution(time).get();
Assert.assertEquals(1, timeFromLastExecution.getSeconds());
@brusazorzo thank you for reporting this. Best!
All tests for this issue are passing now. It might be fixed by some fixes on another daylight saving issue? @jmrozanec
@IndeedSi not all tests are passing. Two are ignored, which require fixing.
@jmrozanec Ah... I meant the two ignored tests were also passing in my local.
@IndeedSi they are not passing in my local ... I just checked again with the latest changes, and found the test failing are Issue404Test::testNovember3Noon and Issue404Test::testNovember3Midnight. Is there any additional code that shall be pushed?
@jmrozanec That's weird.... I tried to change my local timezone, still found these tests passing. Not sure how I can reproduce the problem here :( (I've got clean master branch, so no additional code in my local)
Issue404Test::testNovember3Noon and Issue404Test::testNovember3Midnight are also passing for me.
Tests were run on AdoptOpenJDK 8.0.242.08-hotspot.
Notably, Brazil seems to have stopped observing DST in 2019, and the update for the jdk for that is in 13.0.1, 11.0.5, 8u231, 7u241.
When I try to run the tests in JDK 8u202, the tests fail.
@pangyikhei thank you for providing a second eye on this! Can we ensure this runs with gh-actions?
@jmrozanec Updated my previous comment with the possible cause of the test failures on your end.
@pangyikhei thanks!