pg_when
pg_when : Natural language time parsing for PostgreSQL
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 1120 | pg_when
|
pg_when
|
0.1.9 |
TIME
|
MIT
|
Rust
|
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--s-d--
|
No
|
Yes
|
No
|
Yes
|
no
|
no
|
manually upgraded PGRX from 0.15.0 to 0.17.0 by Vonng
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY
|
0.1.9 |
18
17
16
15
14
|
pg_when |
- |
| RPM | PIGSTY
|
0.1.9 |
18
17
16
15
14
|
pg_when_$v |
- |
| DEB | PIGSTY
|
0.1.9 |
18
17
16
15
14
|
postgresql-$v-pg-when |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
el8.aarch64
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
el9.x86_64
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
el9.aarch64
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
el10.x86_64
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
el10.aarch64
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
d12.x86_64
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
d12.aarch64
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
d13.x86_64
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
d13.aarch64
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
u22.x86_64
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
u22.aarch64
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
u24.x86_64
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
u24.aarch64
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
PIGSTY 0.1.9
|
Source
pig build pkg pg_when; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install pg_when; # install via package name, for the active PG version
pig install pg_when -v 18; # install for PG 18
pig install pg_when -v 17; # install for PG 17
pig install pg_when -v 16; # install for PG 16
pig install pg_when -v 15; # install for PG 15
pig install pg_when -v 14; # install for PG 14Create this extension with:
CREATE EXTENSION pg_when;Usage
Sources: README and project repo.
pg-when is a PostgreSQL extension for creating time values from natural-language phrases.
It exposes the same parsed expression through multiple return formats:
when_is, seconds_at, millis_at, micros_at, and nanos_at.
The query syntax combines up to three parts:
SELECT when_is('<date> at <time> in <timezone>');
SELECT when_is('<date>');
SELECT when_is('<time> in <timezone>');
SELECT when_is('<date> at <time>');If no timezone is provided, the extension defaults to UTC.
Supported Components
<date> can be relative or exact.
Relative date examples from the README include:
todayyesterdaytomorrownext weeklast monththis friday5 days agoin 2 years
Exact dates can be written as:
YYYY-MM-DDorYYYY/MM/DDDD-MM-YYYYorDD/MM/YYYYMonth D, YYYYD Month YYYY
<time> can also be relative or exact.
Relative time examples include:
noonmidnightmorningeveningnext hourprevious minutethis hour
Exact times can be written in 12-hour or 24-hour forms such as 8:30 pm or 15:45.
Timezones accept either IANA names or UTC offsets, for example America/New_York or UTC-08:00.
Examples
SELECT when_is('5 days ago at this hour in Asia/Tokyo');
SELECT when_is('next friday at 8:00 pm in America/New_York');
SELECT when_is('in 2 months at midnight in UTC-8');
SELECT when_is('last monday at 22:30');
SELECT when_is('December 31, 2026 at evening');Deployment
The upstream README shows Docker images for PostgreSQL 13 through 18. That matches the package metadata in this repository.