pgcalendar
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pgcalendar | 1.1.0 | TYPE | MIT | SQL |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 3890 | pgcalendar | No | No | No | Yes | No | No | pgcalendar |
| Related | periods temporal_tables timeseries pg_cron |
|---|
Deb/RPM recipes patch the stale upstream 1.1.0 control metadata (default_version/module_pathname).
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.1.0 | 1817161514 | pgcalendar | - |
| RPM | PIGSTY | 1.1.0 | 1817161514 | pgcalendar_$v | - |
| DEB | PIGSTY | 1.1.0 | 1817161514 | postgresql-$v-pgcalendar | - |
Build
You can build the RPM / DEB packages for pgcalendar using pig build:
pig build pkg pgcalendar # build RPM / DEB packages
Install
You can install pgcalendar directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
pig repo add pgsql -u # Add repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install pgcalendar; # Install for current active PG version
pig ext install -y pgcalendar -v 18 # PG 18
pig ext install -y pgcalendar -v 17 # PG 17
pig ext install -y pgcalendar -v 16 # PG 16
pig ext install -y pgcalendar -v 15 # PG 15
pig ext install -y pgcalendar -v 14 # PG 14
dnf install -y pgcalendar_18 # PG 18
dnf install -y pgcalendar_17 # PG 17
dnf install -y pgcalendar_16 # PG 16
dnf install -y pgcalendar_15 # PG 15
dnf install -y pgcalendar_14 # PG 14
apt install -y postgresql-18-pgcalendar # PG 18
apt install -y postgresql-17-pgcalendar # PG 17
apt install -y postgresql-16-pgcalendar # PG 16
apt install -y postgresql-15-pgcalendar # PG 15
apt install -y postgresql-14-pgcalendar # PG 14
Create Extension:
CREATE EXTENSION pgcalendar;
Usage
Syntax:
CREATE EXTENSION pgcalendar; INSERT INTO pgcalendar.events (name, description, category) VALUES ('Daily Standup', 'Team daily standup meeting', 'meeting'); SELECT * FROM pgcalendar.get_event_projections(1, '2024-01-01'::date, '2024-01-07'::date);Source: README
pgcalendar is a recurring calendar extension for PostgreSQL. It models events, schedules, exceptions, and projections, and generates calendar occurrences across arbitrary date ranges.
Data Model
The README describes four main concepts:
eventsas logical objects such as meetings or tasksschedulesas non-overlapping recurrence definitionsexceptionsas per-occurrence cancellations or modificationsprojectionsas the actual generated calendar occurrences
Quick Start
Create an event:
INSERT INTO pgcalendar.events (name, description, category)
VALUES ('Daily Standup', 'Team daily standup meeting', 'meeting');
Create a schedule:
INSERT INTO pgcalendar.schedules (
event_id, start_date, end_date, recurrence_type, recurrence_interval
) VALUES (
1, '2024-01-01 09:00:00', '2024-01-07 23:59:59', 'daily', 1
);
Get projections:
SELECT * FROM pgcalendar.get_event_projections(
1, '2024-01-01'::date, '2024-01-07'::date
);
Recurrence Types
The README shows schedule examples for:
- daily recurrence
- weekly recurrence with
recurrence_day_of_week - monthly recurrence with
recurrence_day_of_month - yearly recurrence with
recurrence_monthandrecurrence_day_of_month
Exceptions
Exceptions can cancel or modify a single occurrence:
INSERT INTO pgcalendar.exceptions (
schedule_id, exception_date, exception_type, notes
) VALUES (
1, '2024-01-15', 'cancelled', 'Holiday - meeting cancelled'
);
Modified occurrences can also change date and time.
Functions and Views
The README documents:
get_event_projections(event_id, start_date, end_date)get_events_detailed(start_date, end_date)transition_event_schedule(...)check_schedule_overlap(event_id, start_date, end_date)pgcalendar.event_calendar
transition_event_schedule(...) safely switches an event to a new schedule definition, while check_schedule_overlap(...) validates that new schedules do not overlap existing ones.
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.