pgcalendar

pgcalendar

pgcalendar : Recurring calendar, schedule, and exception management for PostgreSQL

Overview

ID Extension Package Version Category License Language
3890
pgcalendar
pgcalendar
1.1.0
TYPE
MIT
SQL
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
----d--
No
No
No
Yes
no
no
Relationships
Schemas pgcalendar
See Also
periods
temporal_tables
timeseries
pg_cron

Deb/RPM recipes patch the stale upstream 1.1.0 control metadata (default_version/module_pathname).

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PIGSTY
1.1.0
18
17
16
15
14
pgcalendar -
RPM
PIGSTY
1.1.0
18
17
16
15
14
pgcalendar_$v -
DEB
PIGSTY
1.1.0
18
17
16
15
14
postgresql-$v-pgcalendar -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
el8.aarch64
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
el9.x86_64
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
el9.aarch64
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
el10.x86_64
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
el10.aarch64
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
d12.x86_64
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
d12.aarch64
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
d13.x86_64
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
d13.aarch64
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
u22.x86_64
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
u22.aarch64
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
u24.x86_64
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
u24.aarch64
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
Package Version OS ORG SIZE File URL
pgcalendar_18 1.1.0 el8.x86_64 pigsty 13.5 KiB pgcalendar_18-1.1.0-1PIGSTY.el8.noarch.rpm
pgcalendar_18 1.1.0 el8.aarch64 pigsty 13.5 KiB pgcalendar_18-1.1.0-1PIGSTY.el8.noarch.rpm
pgcalendar_18 1.1.0 el9.x86_64 pigsty 13.4 KiB pgcalendar_18-1.1.0-1PIGSTY.el9.noarch.rpm
pgcalendar_18 1.1.0 el9.aarch64 pigsty 13.4 KiB pgcalendar_18-1.1.0-1PIGSTY.el9.noarch.rpm
pgcalendar_18 1.1.0 el10.x86_64 pigsty 13.6 KiB pgcalendar_18-1.1.0-1PIGSTY.el10.noarch.rpm
pgcalendar_18 1.1.0 el10.aarch64 pigsty 13.5 KiB pgcalendar_18-1.1.0-1PIGSTY.el10.noarch.rpm
postgresql-18-pgcalendar 1.1.0 d12.x86_64 pigsty 7.3 KiB postgresql-18-pgcalendar_1.1.0-1PIGSTY~bookworm_amd64.deb
postgresql-18-pgcalendar 1.1.0 d12.aarch64 pigsty 7.3 KiB postgresql-18-pgcalendar_1.1.0-1PIGSTY~bookworm_arm64.deb
postgresql-18-pgcalendar 1.1.0 d13.x86_64 pigsty 7.3 KiB postgresql-18-pgcalendar_1.1.0-1PIGSTY~trixie_amd64.deb
postgresql-18-pgcalendar 1.1.0 d13.aarch64 pigsty 7.3 KiB postgresql-18-pgcalendar_1.1.0-1PIGSTY~trixie_arm64.deb
postgresql-18-pgcalendar 1.1.0 u22.x86_64 pigsty 7.4 KiB postgresql-18-pgcalendar_1.1.0-1PIGSTY~jammy_amd64.deb
postgresql-18-pgcalendar 1.1.0 u22.aarch64 pigsty 7.4 KiB postgresql-18-pgcalendar_1.1.0-1PIGSTY~jammy_arm64.deb
postgresql-18-pgcalendar 1.1.0 u24.x86_64 pigsty 7.4 KiB postgresql-18-pgcalendar_1.1.0-1PIGSTY~noble_amd64.deb
postgresql-18-pgcalendar 1.1.0 u24.aarch64 pigsty 7.4 KiB postgresql-18-pgcalendar_1.1.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pgcalendar_17 1.1.0 el8.x86_64 pigsty 13.5 KiB pgcalendar_17-1.1.0-1PIGSTY.el8.noarch.rpm
pgcalendar_17 1.1.0 el8.aarch64 pigsty 13.5 KiB pgcalendar_17-1.1.0-1PIGSTY.el8.noarch.rpm
pgcalendar_17 1.1.0 el9.x86_64 pigsty 13.4 KiB pgcalendar_17-1.1.0-1PIGSTY.el9.noarch.rpm
pgcalendar_17 1.1.0 el9.aarch64 pigsty 13.4 KiB pgcalendar_17-1.1.0-1PIGSTY.el9.noarch.rpm
pgcalendar_17 1.1.0 el10.x86_64 pigsty 13.6 KiB pgcalendar_17-1.1.0-1PIGSTY.el10.noarch.rpm
pgcalendar_17 1.1.0 el10.aarch64 pigsty 13.5 KiB pgcalendar_17-1.1.0-1PIGSTY.el10.noarch.rpm
postgresql-17-pgcalendar 1.1.0 d12.x86_64 pigsty 7.3 KiB postgresql-17-pgcalendar_1.1.0-1PIGSTY~bookworm_amd64.deb
postgresql-17-pgcalendar 1.1.0 d12.aarch64 pigsty 7.3 KiB postgresql-17-pgcalendar_1.1.0-1PIGSTY~bookworm_arm64.deb
postgresql-17-pgcalendar 1.1.0 d13.x86_64 pigsty 7.3 KiB postgresql-17-pgcalendar_1.1.0-1PIGSTY~trixie_amd64.deb
postgresql-17-pgcalendar 1.1.0 d13.aarch64 pigsty 7.3 KiB postgresql-17-pgcalendar_1.1.0-1PIGSTY~trixie_arm64.deb
postgresql-17-pgcalendar 1.1.0 u22.x86_64 pigsty 7.4 KiB postgresql-17-pgcalendar_1.1.0-1PIGSTY~jammy_amd64.deb
postgresql-17-pgcalendar 1.1.0 u22.aarch64 pigsty 7.4 KiB postgresql-17-pgcalendar_1.1.0-1PIGSTY~jammy_arm64.deb
postgresql-17-pgcalendar 1.1.0 u24.x86_64 pigsty 7.4 KiB postgresql-17-pgcalendar_1.1.0-1PIGSTY~noble_amd64.deb
postgresql-17-pgcalendar 1.1.0 u24.aarch64 pigsty 7.4 KiB postgresql-17-pgcalendar_1.1.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pgcalendar_16 1.1.0 el8.x86_64 pigsty 13.5 KiB pgcalendar_16-1.1.0-1PIGSTY.el8.noarch.rpm
pgcalendar_16 1.1.0 el8.aarch64 pigsty 13.5 KiB pgcalendar_16-1.1.0-1PIGSTY.el8.noarch.rpm
pgcalendar_16 1.1.0 el9.x86_64 pigsty 13.4 KiB pgcalendar_16-1.1.0-1PIGSTY.el9.noarch.rpm
pgcalendar_16 1.1.0 el9.aarch64 pigsty 13.4 KiB pgcalendar_16-1.1.0-1PIGSTY.el9.noarch.rpm
pgcalendar_16 1.1.0 el10.x86_64 pigsty 13.6 KiB pgcalendar_16-1.1.0-1PIGSTY.el10.noarch.rpm
pgcalendar_16 1.1.0 el10.aarch64 pigsty 13.5 KiB pgcalendar_16-1.1.0-1PIGSTY.el10.noarch.rpm
postgresql-16-pgcalendar 1.1.0 d12.x86_64 pigsty 7.3 KiB postgresql-16-pgcalendar_1.1.0-1PIGSTY~bookworm_amd64.deb
postgresql-16-pgcalendar 1.1.0 d12.aarch64 pigsty 7.3 KiB postgresql-16-pgcalendar_1.1.0-1PIGSTY~bookworm_arm64.deb
postgresql-16-pgcalendar 1.1.0 d13.x86_64 pigsty 7.3 KiB postgresql-16-pgcalendar_1.1.0-1PIGSTY~trixie_amd64.deb
postgresql-16-pgcalendar 1.1.0 d13.aarch64 pigsty 7.3 KiB postgresql-16-pgcalendar_1.1.0-1PIGSTY~trixie_arm64.deb
postgresql-16-pgcalendar 1.1.0 u22.x86_64 pigsty 7.4 KiB postgresql-16-pgcalendar_1.1.0-1PIGSTY~jammy_amd64.deb
postgresql-16-pgcalendar 1.1.0 u22.aarch64 pigsty 7.4 KiB postgresql-16-pgcalendar_1.1.0-1PIGSTY~jammy_arm64.deb
postgresql-16-pgcalendar 1.1.0 u24.x86_64 pigsty 7.4 KiB postgresql-16-pgcalendar_1.1.0-1PIGSTY~noble_amd64.deb
postgresql-16-pgcalendar 1.1.0 u24.aarch64 pigsty 7.4 KiB postgresql-16-pgcalendar_1.1.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pgcalendar_15 1.1.0 el8.x86_64 pigsty 13.5 KiB pgcalendar_15-1.1.0-1PIGSTY.el8.noarch.rpm
pgcalendar_15 1.1.0 el8.aarch64 pigsty 13.5 KiB pgcalendar_15-1.1.0-1PIGSTY.el8.noarch.rpm
pgcalendar_15 1.1.0 el9.x86_64 pigsty 13.4 KiB pgcalendar_15-1.1.0-1PIGSTY.el9.noarch.rpm
pgcalendar_15 1.1.0 el9.aarch64 pigsty 13.4 KiB pgcalendar_15-1.1.0-1PIGSTY.el9.noarch.rpm
pgcalendar_15 1.1.0 el10.x86_64 pigsty 13.6 KiB pgcalendar_15-1.1.0-1PIGSTY.el10.noarch.rpm
pgcalendar_15 1.1.0 el10.aarch64 pigsty 13.5 KiB pgcalendar_15-1.1.0-1PIGSTY.el10.noarch.rpm
postgresql-15-pgcalendar 1.1.0 d12.x86_64 pigsty 7.3 KiB postgresql-15-pgcalendar_1.1.0-1PIGSTY~bookworm_amd64.deb
postgresql-15-pgcalendar 1.1.0 d12.aarch64 pigsty 7.3 KiB postgresql-15-pgcalendar_1.1.0-1PIGSTY~bookworm_arm64.deb
postgresql-15-pgcalendar 1.1.0 d13.x86_64 pigsty 7.3 KiB postgresql-15-pgcalendar_1.1.0-1PIGSTY~trixie_amd64.deb
postgresql-15-pgcalendar 1.1.0 d13.aarch64 pigsty 7.3 KiB postgresql-15-pgcalendar_1.1.0-1PIGSTY~trixie_arm64.deb
postgresql-15-pgcalendar 1.1.0 u22.x86_64 pigsty 7.4 KiB postgresql-15-pgcalendar_1.1.0-1PIGSTY~jammy_amd64.deb
postgresql-15-pgcalendar 1.1.0 u22.aarch64 pigsty 7.4 KiB postgresql-15-pgcalendar_1.1.0-1PIGSTY~jammy_arm64.deb
postgresql-15-pgcalendar 1.1.0 u24.x86_64 pigsty 7.4 KiB postgresql-15-pgcalendar_1.1.0-1PIGSTY~noble_amd64.deb
postgresql-15-pgcalendar 1.1.0 u24.aarch64 pigsty 7.4 KiB postgresql-15-pgcalendar_1.1.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pgcalendar_14 1.1.0 el8.x86_64 pigsty 13.5 KiB pgcalendar_14-1.1.0-1PIGSTY.el8.noarch.rpm
pgcalendar_14 1.1.0 el8.aarch64 pigsty 13.5 KiB pgcalendar_14-1.1.0-1PIGSTY.el8.noarch.rpm
pgcalendar_14 1.1.0 el9.x86_64 pigsty 13.4 KiB pgcalendar_14-1.1.0-1PIGSTY.el9.noarch.rpm
pgcalendar_14 1.1.0 el9.aarch64 pigsty 13.4 KiB pgcalendar_14-1.1.0-1PIGSTY.el9.noarch.rpm
pgcalendar_14 1.1.0 el10.x86_64 pigsty 13.6 KiB pgcalendar_14-1.1.0-1PIGSTY.el10.noarch.rpm
pgcalendar_14 1.1.0 el10.aarch64 pigsty 13.5 KiB pgcalendar_14-1.1.0-1PIGSTY.el10.noarch.rpm
postgresql-14-pgcalendar 1.1.0 d12.x86_64 pigsty 7.3 KiB postgresql-14-pgcalendar_1.1.0-1PIGSTY~bookworm_amd64.deb
postgresql-14-pgcalendar 1.1.0 d12.aarch64 pigsty 7.3 KiB postgresql-14-pgcalendar_1.1.0-1PIGSTY~bookworm_arm64.deb
postgresql-14-pgcalendar 1.1.0 d13.x86_64 pigsty 7.3 KiB postgresql-14-pgcalendar_1.1.0-1PIGSTY~trixie_amd64.deb
postgresql-14-pgcalendar 1.1.0 d13.aarch64 pigsty 7.3 KiB postgresql-14-pgcalendar_1.1.0-1PIGSTY~trixie_arm64.deb
postgresql-14-pgcalendar 1.1.0 u22.x86_64 pigsty 7.4 KiB postgresql-14-pgcalendar_1.1.0-1PIGSTY~jammy_amd64.deb
postgresql-14-pgcalendar 1.1.0 u22.aarch64 pigsty 7.4 KiB postgresql-14-pgcalendar_1.1.0-1PIGSTY~jammy_arm64.deb
postgresql-14-pgcalendar 1.1.0 u24.x86_64 pigsty 7.4 KiB postgresql-14-pgcalendar_1.1.0-1PIGSTY~noble_amd64.deb
postgresql-14-pgcalendar 1.1.0 u24.aarch64 pigsty 7.4 KiB postgresql-14-pgcalendar_1.1.0-1PIGSTY~noble_arm64.deb

Source

pig build pkg pgcalendar;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pgcalendar;		# install via package name, for the active PG version

pig install pgcalendar -v 18;   # install for PG 18
pig install pgcalendar -v 17;   # install for PG 17
pig install pgcalendar -v 16;   # install for PG 16
pig install pgcalendar -v 15;   # install for PG 15
pig install pgcalendar -v 14;   # install for PG 14

Create this extension with:

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:

  • events as logical objects such as meetings or tasks
  • schedules as non-overlapping recurrence definitions
  • exceptions as per-occurrence cancellations or modifications
  • projections as 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_month and recurrence_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.

Last updated on