Skip to content

Commit

Permalink
PRESIDECMS-2983 ensure next run date is in local format.
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicWatson committed Dec 10, 2024
1 parent ba753cf commit 44ac067
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion system/services/taskmanager/CronUtil.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ component displayName="Cron util" {
var cronTabExpression = _getCrontabExpressionObject( arguments.crontabExpression );
var executionTimeObj = CreateObject( "java", "com.cronutils.model.time.ExecutionTime", _getLib() ).forCron( cronTabExpression );

return executionTimeObj.nextExecution( _createJavaZonedTimeObject( arguments.lastRun ) ).get().toString();
return executionTimeObj.nextExecution( _createJavaZonedTimeObject( arguments.lastRun ) ).get().format( variables._dateTimeFormat );
}

public string function describeCronTabExression( required string crontabExpression, required string locale ) {
Expand Down Expand Up @@ -94,6 +94,7 @@ component displayName="Cron util" {
if ( Left( variables._timezoneOffset, "1" ) != "-" ) {
variables._timezoneOffset = "+" & variables._timezoneOffset;
}
variables._dateTimeFormat = CreateObject( "java", "java.time.format.DateTimeFormatter" ).ISO_LOCAL_DATE_TIME;
}

}
4 changes: 2 additions & 2 deletions tests/unit/api/taskmanager/TaskManagerServiceTest.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ component extends="testbox.system.BaseSpec" {

var nextRun = tm.getNextRunDate( taskKey, lastRun );

expect( nextRun ).toBe( "2014-10-24T09:05Z" );
expect( nextRun ).toBe( "2014-10-24T09:05" );
} );

it( "shoud use the current date when no last run date passed", function(){
Expand Down Expand Up @@ -342,7 +342,7 @@ component extends="testbox.system.BaseSpec" {

var nextRun = tm.getNextRunDate( taskKey, lastRun );

expect( nextRun ).toBe( "2014-10-24T09:10Z" );
expect( nextRun ).toBe( "2014-10-24T09:10" );
} );

it( "should return an empty string when task is not a scheduled task", function(){
Expand Down

0 comments on commit 44ac067

Please sign in to comment.