Repository navigation
The first release. One install script (jdate--1.0.sql), no upgrade scripts.
Requires PostgreSQL 16 or later; the regression suite runs in CI on 16, 17 and 18.
Types
jdate: a 4-byte base type for the Jalali (Persian / Solar Hijri) calendar,
binary-compatible withdate. Text I/OYYYY-MM-DD,infinityand
-infinity, binary I/O indate's wire format, an array type. Supported days
are Jalali-0061-01-01to3177-12-29(Gregorian0560-03-20to
3799-03-19), with the calendar algorithm of Kazimierz M. Borkowski (the one
used byjalaali-js).jtimestampandjtimestamptz: 8-byte types with the representation and
binary format oftimestampandtimestamptz, Jalali text input and output,
optional fractional-second typmod.jtimestamptzaccepts a safe range that is
the Jalali range less 16 hours at each end.jdaterange,jtsrange,jtstzrangeand their multirange types, with a
canonical function that range-checks the bound (so the last supported day is
the edge ofjdaterange). Operators,range_agg, GiST and SP-GiST indexes and
EXCLUDEconstraints come from core's generic range code and are tested.
Operators, indexing and casts
- Comparison operators, default btree and hash operator classes (
jdate_ops,
jdate_hash_ops,jtimestamp_ops,jtimestamp_hash_ops,jtimestamptz_ops,
jtimestamptz_hash_ops), so sorting,GROUP BY,DISTINCT, hash joins, btree
and hash indexes andPARTITION BY HASHwork natively.min()andmax(). - Cross-type comparison of
jdate,jtimestampandjtimestamptzin one shared
btree operator family. - Restriction estimators for
<,<=,>and>=that pair a lower and an upper
bound, so a narrowBETWEENon any of the three types is estimated like core's
own types instead of at one row or a whole histogram bucket. - Casts to and from
date,timestampandtimestamptz, range-checked in the
direction where core covers more days than the Jalali algorithm. There are no
implicit casts between the timestamp types.
Functions and arithmetic
jdate + int,jdate - int,jdate - jdate;+and-withintervalfor
all three types, using Jalali months (clamped to the month end) and, for
jtimestamptz, daylight-saving rules;jdate + timeandjdate + timetz.EXTRACTandjdate_part(Saturday-firstdow, ISOisodow),jdate_trunc
(week starts on Saturday),jdate_bin,jgenerate_serieswith Jalali month
steps,AT TIME ZONE,OVERLAPS,to_jdate,
to_jtimestamptz,jdate_formatand the text keysjday_formatand
jmonth_formatforGROUP BYand for indexes.- Soft errors in text input (
pg_input_is_valid,pg_input_error_info;
COPY ... (ON_ERROR ignore)on PostgreSQL 17 and later). Whitespace around
infinityis accepted, as in the core input functions. - Volatility and parallel safety are declared per function and checked by the
tests;jtimestamptzfunctions that read the session time zone areSTABLE,
and the index recipes that need a fixed zone are documented.
Packaging
- Not relocatable: nine overloads of
extract,timezoneandoverlapslive in
pg_catalogso that theEXTRACT,AT TIME ZONEandOVERLAPSsyntaxes
work. Choose the schema at install:CREATE EXTENSION jdate SCHEMA s. - Installing needs a superuser.
Verification
- A standalone exhaustive test of the calendar code, 36
pg_regressfiles, a
pg_dump/ restore round trip (plain,--insertsand custom format, default
and custom schema), apgbenchconcurrency stress run, an every-day
jtimestamptzsweep, a full-range sweep and a performance report. CI runs
these on PostgreSQL 16, 17 and 18. See docs/TESTING.md.