jmrozanec / jmrozanec/cron-utils

timeFromLastExecution with zoneId ignores november 3

Open
#404 10 comments 0 reactions 0 assignees View on GitHub
bug hacktoberfest help wanted
Dominant language
Java
Stars
1.2k
Forks
272
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.