Page MenuHomePhabricator

Rough cut of implementing some of RRULE behaviors
ClosedPublic

Authored by epriestley on Sep 26 2016, 10:50 PM.
Tags
None
Referenced Files
F14073601: D16599.diff
Thu, Nov 21, 1:26 AM
Unknown Object (File)
Mon, Nov 4, 3:10 AM
Unknown Object (File)
Oct 22 2024, 11:33 AM
Unknown Object (File)
Oct 21 2024, 9:49 AM
Unknown Object (File)
Oct 19 2024, 6:19 AM
Unknown Object (File)
Sep 12 2024, 1:14 PM
Unknown Object (File)
Sep 12 2024, 10:49 AM
Unknown Object (File)
Sep 12 2024, 10:48 AM
Subscribers
None

Details

Summary

Ref T10747. This isn't done and literally took me all day, but the basics are kind of working and I think I mostly just have to fill in a few more things and then heap piles and piles of tests on it.

Here's an RRULE that is difficult to evaluate quickly:

$rrule = id(new PhutilCalendarRecurrenceRule())
  ->setStartDateTime($start)
  ->setFrequency('SECONDLY')
  ->setByMonth(array(1))
  ->setByMonthDay(array(1))
  ->setByHour(array(12))
  ->setByMinute(array(0))
  ->setBySecond(array(0));

Here's how long it takes to evaluate on various RRULE libraries:

PhutilCalendarRecurrenceRuleInstantaneous
php-rrule11 seconds
rrule.jsCompletely Freezes
python-dateutil7 seconds
recurr (PHP)Didn't actually test it, but looks like the same code

Apparently someone wrote python-dateutil, and then people have just been porting that to other languages ever since. python-dateutil is not very fast at evaluating these kinds of rules, and all of the ports seem worse.

In the case of recurr, it looks like someone ported python-dateutil to JS (rrule.js), then ported the JS to PHP.

The structure of all these libraries appears essentially the same, and they pretty much brute force their way through evaluating rules like this.

It isn't really important to be able to evaluate this rule quickly, and I haven't finished this implementation so may approach may actually be garbage that I have to throw out, but being dramatically better in one contrived edge case makes me feel like I accomplished something more than gaining a deeper personal understanding of RRULEs by implementing this.

Test Plan

Unit tests.

Diff Detail

Repository
rPHU libphutil
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

epriestley retitled this revision from to Rough cut of implementing some of RRULE behaviors.
epriestley updated this object.
epriestley edited the test plan for this revision. (Show Details)
epriestley added a reviewer: chad.

PHP iCalendar! Brute force ftw!

chad edited edge metadata.
This revision is now accepted and ready to land.Sep 27 2016, 6:02 AM
This revision was automatically updated to reflect the committed changes.