Closed FRDS closed 5 years ago
I am not sure you can have tested the code provided.
numberofDays()
should be numberOfDays()
protected
method and for internal use only$event->$dtstart_array[2]
should be $event->dtstart_array[2]
$event->$dtend_array[2]
should be $event->dtend_array[2]
endforeach
$days
has not been definedAs you have Carbon at your disposal I would do the following.
<?php
use Carbon\Carbon;
// Load iCal...
$events = $ical->eventsFromRange('2018-12-01 00:00:00', '2018-12-31 23:59:59');
$days = 0;
foreach ($events as $event) :
$end = Carbon::createFromTimestamp($event->dtend_array[2]);
$start = Carbon::createFromTimestamp($event->dtstart_array[2]);
$days += $end->diffInDays($start);
endforeach;
var_dump($days);
8 days
so hopefully that is what you were looking for.
7.3.0
2.1.7
Description of the Issue:
I want to quickly sum days of events in a time range (i.e month of October 2018). I've tried to use the
numberofDays
method but I don't actually know how to use it :$days
?$start
and$end
should I use?Without knowing the answers I've tried it anyway, getting this:
Uncaught Error: Call to protected method ICal\ICal::numberofDays() from context
Here's the ICS file URL (it can't be used for
initURL
, so you need to download it first) : https://www.airbnb.com/calendar/ical/2051868.ics?s=0624fe394b3084d9f07ae453082c76e9Code that I've tested: