kylekatarnls / business-time

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

Add Days #20

Closed FuriosoJack closed 4 years ago

FuriosoJack commented 4 years ago

How can I add days and that does not count the opening days. I mean I have this opening setting

'monday' => ['09: 00-12: 00', '13: 00-18: 00 '],   'tuesday' => ['09: 00-12: 00 ', '13: 00-18: 00'],   'wednesday' => ['09: 00-12: 00 '], 'thursday' => ['09: 00-12: 00 ', '13: 00-18: 00'],   'friday' => ['09: 00-12: 00 ', '13: 00-18: 00'], 'saturday' => [],   'sunday' => [], the current date is 2020-12-20 they take two days and you must return the date 2020-12-26

on the 26th because since the 20th is Friday and Saturday and Sunday there is no work and the 25th is a holiday,

is it compressible?

kylekatarnls commented 4 years ago

2020-12-20 is a Sunday so it's a bit difficult to understand your example. If I understand, you want to:

$date = Carbon::parse('2020-12-20');

for ($i = 0; $i < 2; $i++) {
  $date->nextCloseIncludingHolidays();
}
FuriosoJack commented 4 years ago

2020-12-20 es un domingo, por lo que es un poco difícil entender su ejemplo. Si entiendo, quieres:

$ date  =  Carbon :: parse ( ' 2020-12-20 ' );

para ( $ i  =  0 ; $ i  <  2 ; $ i ++ ) { 
$ date -> nextCloseIncludingHolidays (); }  

No thank you very much, it is not specified here but in the business-day documentation if it is addDayBusiness () and it was the one I needed.