Skip to content

Commit ce5299e

Browse files
DateTimeHelper BugFix and Test Update (#591)
- Fixed bug in string concatenation - Added toString() on argument test required by Lucee when a numeric value is sent in - Updated Test Spec with new test for validateTime and name COLDBOX-1281 #resolve
1 parent a12a62f commit ce5299e

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

system/async/time/DateTimeHelper.cfc

+2-2
Original file line numberDiff line numberDiff line change
@@ -294,15 +294,15 @@ component singleton {
294294
*/
295295
string function validateTime( required string time ){
296296
if ( !reFind( "^([0-1][0-9]|[2][0-3])\:[0-5][0-9]$", arguments.time ) ) {
297-
if ( arguments.time.findOneOf( ":" ) > 0 ) {
297+
if ( arguments.time.toString().findOneOf( ":" ) > 0 ) {
298298
throw(
299299
message = "Invalid time representation (#arguments.time#). Time is represented in 24 hour minute format => HH:mm",
300300
type = "InvalidTimeException"
301301
);
302302
}
303303

304304
// There were no minutes, so let's add them
305-
return validateTime( arguments.time + ":00" );
305+
return validateTime( arguments.time & ":00" );
306306
}
307307

308308
return arguments.time;

tests/specs/async/time/ChronoUnitSpec.cfc renamed to tests/specs/async/time/DateTimeHelperSpec.cfc

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ component extends="tests.specs.async.BaseAsyncSpec" {
77

88
function run( testResults, testBox ){
99
// all your suites go here.
10-
describe( "Chrono Units", function(){
10+
describe( "Date Time Helper", function(){
1111
beforeEach( function( currentSpec ){
1212
dateTimeHelper = new coldbox.system.async.time.DateTimeHelper();
1313
} );
@@ -41,6 +41,11 @@ component extends="tests.specs.async.BaseAsyncSpec" {
4141
expect( t.getId() ).notToBeEmpty();
4242
} );
4343

44+
it( "can validate a numeric time value", function(){
45+
var timeValue = dateTimeHelper.validateTime( 11 );
46+
expect( timeValue ).toBe( "11:00" );
47+
} );
48+
4449
var units = [
4550
"CENTURIES",
4651
"DAYS",

0 commit comments

Comments
 (0)