kylekatarnls / business-time

Carbon mixin to handle business days and opening hours
MIT License
296 stars 14 forks source link

DiffInBusiness* does not work with LOCAL_MODE #39

Closed Naghal closed 3 years ago

Naghal commented 3 years ago

Hi! I am having the same problem as in issue #31, but this time with diffInBusiness methods. I am using latest version of this package. (1.9.1)

Example:

$openingHour = $this->getOpeningHour();
$openingHourSchedule = $openingHour->getSerializedSchedule($this->openingHourArraySerialiser);
$openingDate = Carbon::parse($this->ticket->getSlaStartPointDate())->setOpeningHours($openingHourSchedule);
$endDate = Carbon::parse($this->ticket->ClosedDate)->setOpeningHours($openingHourSchedule);

if I call $openingDate->getCurrentOpenTimePeriod(), it returns the correct opening hours image

However, I cannot call $openingDate->diffInBusinessHours($endDate); as it result in the following error:

exception: "BusinessTime\Exceptions\InvalidArgumentException"
file: "/app/vendor/cmixin/business-time/src/BusinessTime/MixinBase.php"
line: 300
message: "Opening hours have not been set."
kylekatarnls commented 3 years ago

This is fixed in 1.9.2. Thanks for the report.

kylekatarnls commented 3 years ago

Side note: the $endDate here does not need to have $openingHourSchedule set, only the start date opening hours are used.

Naghal commented 3 years ago

Thank you, it is working!