jmrozanec / cron-utils

Cron utils for parsing, validations and human readable descriptions as well as date/time interoperability.
http://cron-utils.com
Apache License 2.0
1.14k stars 262 forks source link

ExecutionTime.nextExecution/timeToNextExecution issue on Daylight Saving Time #623

Closed alexmirash closed 5 months ago

alexmirash commented 5 months ago

//issue test case
private fun test() { val cronString = "0 0 23 ? *" val parser = CronParser(CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ)) val executionTime = ExecutionTime.forCron(parser.parse(cronString)) val time = ZonedDateTime.of(2024, 3, 31, 21, 59, 30, 0, ZoneId.systemDefault()) val nextTime = executionTime.nextExecution(time) val timeToNextExecution = executionTime.timeToNextExecution(time) Log.d(TAG, "time=$time") Log.d(TAG, "nextTime=$nextTime") Log.d(TAG, "timeToNextExecution=$timeToNextExecution") } //output time=2024-03-31T21:59:30+03:00[Europe/Kiev] nextTime=Optional.of(2024-03-01T23:00+02:00[Europe/Kiev]) timeToNextExecution=Optional.of(PT-717H-59M-30S)

alexmirash commented 5 months ago

//this usage variand leads to issue implementation(libs.cron.utils) implementation(libs.threetenabp) -- this library seems to contain issue //this variant does not contain this problem implementation(libs.cron.utils.v920)