cron-utils icon indicating copy to clipboard operation
cron-utils copied to clipboard

timeFromLastExecution with zoneId ignores november 3

Open andrelzorzo opened this issue 6 years ago • 10 comments
trafficstars

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());

andrelzorzo avatar Nov 03 '19 18:11 andrelzorzo

@brusazorzo thank you for reporting this. Best!

jmrozanec avatar Nov 03 '19 19:11 jmrozanec

All tests for this issue are passing now. It might be fixed by some fixes on another daylight saving issue? @jmrozanec

IndeedSi avatar Oct 12 '20 03:10 IndeedSi

@IndeedSi not all tests are passing. Two are ignored, which require fixing.

jmrozanec avatar Oct 13 '20 08:10 jmrozanec

@jmrozanec Ah... I meant the two ignored tests were also passing in my local.

IndeedSi avatar Oct 13 '20 08:10 IndeedSi

@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 avatar Oct 13 '20 08:10 jmrozanec

@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)

IndeedSi avatar Oct 13 '20 12:10 IndeedSi

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 avatar Oct 28 '20 01:10 pangyikhei

@pangyikhei thank you for providing a second eye on this! Can we ensure this runs with gh-actions?

jmrozanec avatar Oct 28 '20 01:10 jmrozanec

@jmrozanec Updated my previous comment with the possible cause of the test failures on your end.

pangyikhei avatar Oct 28 '20 01:10 pangyikhei

@pangyikhei thanks!

jmrozanec avatar Oct 28 '20 01:10 jmrozanec