I am using the BusinessHours class and am just running some basic tests:
BusinessHours bh = [SELECT Id, ThursdayStartTime FROM BusinessHours WHERE IsDefault = true];
if (BusinessHours.isWithin(bh.Id, scheduledDateTime)){ //this will come up as FALSE if the time isn't between 06:00:00.000Z and 17:00:00.000Z
system.debug('BusinessHours.isWithin is true:: ' + scheduledDateTime + ', biz hours: ' + bh.ThursdayStartTime);
}
else {
schedDateTime = BusinessHours.nextStartDate(bh.Id, scheduledDateTime);
system.debug('BusinessHours.isWithin() is false:: ' + scheduledDateTime + ', biz hours: ' + bh.ThursdayStartTime);
}
This prints out: BusinessHours.isWithin is false:: 2018-08-29 07:00:00, biz hours: 06:00:00.000Z
Why would it be false if 7:00am is within the registered business hours?
scheduledDateTime
? 3. Do you have holidays defined? – Jayant Das Aug 9 '18 at 15:20Z
is UTC which means that the UTC time is 2:00pm. Am I incorrect with the UTC information? Could the BusinessHours class be running in a different timezone? – Olivia Aug 9 '18 at 15:35Datetime scheduledDateTime = (Datetime)request.inputParameters.get('varStartDate');
– Olivia Aug 9 '18 at 15:41(GMT+00:00) Greenwich Mean Time (GMT)
– Jayant Das Aug 9 '18 at 16:01