u01jmg3 / ics-parser

Parser for iCalendar Events • PHP 8+, 7 (≥ 7.4), 5 (≥ 5.6)
MIT License
448 stars 144 forks source link

script only returning items of first day #255

Closed vespino closed 4 years ago

vespino commented 4 years ago

I have been using the script for some time now, but recently I noticed some items not being read by the script. Today again. The following only seems to return appointments that occur tomorrow:

$ical=new ICal(
    'link-to-ical-file',
    array(
        'defaultSpan'                 => 2,     // Default value
        'defaultTimeZone'             => 'UTC',
        'defaultWeekStart'            => 'MO',  // Default value
        'disableCharacterReplacement' => false, // Default value
        'filterDaysAfter'             => true,  // Default value
        'filterDaysBefore'            => true,  // Default value
        'skipRecurrence'              => true, // Default value
    )
);

$forceTimeZone=false;

$events=$ical->eventsFromRange(date('Y-m-d', strtotime('tomorrow')).' 00:00:00', date('Y-m-d', strtotime('last day of december this year')).' 23:59:59');

What could I be overlooking? I'm using version 2.1.16 of this script and different versions of PHP (both 5 and 7) since I'm using it on multiple servers.

Edit 2020/1/15: I did some more testing and the script only seems to return "today" and "tomorrow".

s0600204 commented 4 years ago

Both filterDaysAfter and filterDaysBefore are expected to be numbers, not Boolean.

php implicitly typecasts Boolean true to the integer 1; so in the case above you're telling the ics parser to ignore all events outside +/- 1 day from "today" when loading and parsing the ical file.

vespino commented 4 years ago

Wow, I totally overlooked that in the example, although I'm certain it was a boolean before because this was working before. Did it change along the way maybe?

s0600204 commented 4 years ago

Looking into it, no: they've been integers since they were added in Nov 2018 (#190).

Ah well, so long as it's now working as expected...