Parse RRULE statements, and generate occurrences.
Execute postgres-rrule.sql
in your database:
$ psql -X -f postgres-rrule.sql
Or
$ make all
And modify your search path to include _rrule
schema:
SET search_path TO public, _rrule;
Requires pgTAP
and pg_resolve
. First let's install those from CPAN.
$ sudo cpan TAP::Parser::SourceHandler::pgTAP
Now you can run the tests with
$ make all test
This repo is a fork of Matthew Schinckel's original repo. I have cleaned up some functions and fixed a few tests. There are still a few broken tests that I couldn't fix. If you can lend a help, please create an issue on this repo.
We create a table (in a newly created _rrule
schema) called RRULE
to generate start dates from rule criteria. The table constraints enforce the validity of dates in the table.
All of the types and functions are created in that schema.
Operator | Description | Notes | Result |
---|---|---|---|
= |
equal | All parameters match | boolean |
<> |
not equal | Any parameters don't match | boolean |
@> |
contains rrule |
All occurrences generated by second rule would also be generated by first rule | boolean |
<@ |
contained by rrule |
boolean |
In the case of the rrule
functions, there is a second required argument of type timestamp
, which is the "dtstart"
argument of a rruleset
. There is a form for each rrule
-accepting function that accepts a text
value, and parses it.
Function | Return Type | Description | Example | Result |
---|---|---|---|---|
after | timestamp[] |
|||
all_starts | timestamp[] |
|||
before | timestamp[] |
|||
build_interval | interval |
|||
compare_equal | boolean |
|||
compare_not_equal | boolean |
|||
contained_by | boolean |
|||
contains | boolean |
|||
day_array | day[] |
|||
enum_index_of | integer |
|||
explode | rrule[] |
|||
explode_interval | exploded_interval |
|||
factor | integer |
|||
first | timestamp |
|||
integer_array | integer[] |
|||
interval_contains | boolean |
|||
is_finite | boolean |
|||
last | timestamp |
|||
occurrences | timestamp[] |
|||
rrule | rrule |
|||
until | timestamp |
The MIT License (MIT)
Copyright (c) 2015 Matthew Schinckel, 2019 Volkan Unsal