pg_when
pg_when : Natural language time parsing for PostgreSQL
Overview
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --s-d-- | No | Yes | No | Yes | no | no |
| Relationships | |
|---|---|
| See Also | pg_cron pgcalendar pg_rrule cron_utils pgagent pg_task pg_dbms_job pg_duration pg_bikram_sambat pg_dispatch |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.1.10 |
18 17 16 15 14 | pg_when |
- |
| RPM | PIGSTY | 0.1.10 |
18 17 16 15 14 | pg_when_$v |
- |
| DEB | PIGSTY | 0.1.10 |
18 17 16 15 14 | postgresql-$v-pg-when |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 |
| el8.aarch64 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 |
| el9.x86_64 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 |
| el9.aarch64 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 |
| el10.x86_64 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 |
| el10.aarch64 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 |
| d12.x86_64 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 |
| d12.aarch64 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 |
| d13.x86_64 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 |
| d13.aarch64 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 |
| u22.x86_64 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 |
| u22.aarch64 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 |
| u24.x86_64 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 |
| u24.aarch64 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 |
| u26.x86_64 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 |
| u26.aarch64 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 | PIGSTY 0.1.10 |
Source
github.com/frectonz/pg-when
pg_when-0.1.10.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Create this extension with:
Usage
Sources:
- pg_when 0.1.10 on PGXN
- pg_when 0.1.10 README
- pg_when 0.1.10 Cargo manifest
- pg_when 0.1.10 control file
- pg_when 0.1.10 exported functions
- pg_when 0.1.10 relative-date implementation
pg_when 0.1.10 parses a constrained natural-language date and time expression and returns either a PostgreSQL timestamptz value or a Unix epoch value at a selected precision.
Query Shape
A query can contain a date, a time, and a time zone, joined by at and in:
If the time zone is omitted, the parser uses UTC. Supported inputs include relative dates such as tomorrow, last month, and 5 days ago; exact dates in common numeric and month-name forms; relative times such as noon, midnight, and next hour; clock times; IANA time-zone names; and UTC offsets.
Function Index
when_is(text)returnstimestamptz.seconds_at(text)returns Unix epoch seconds.millis_at(text)returns Unix epoch milliseconds.micros_at(text)returns Unix epoch microseconds.nanos_at(text)returns Unix epoch nanoseconds.
Compatibility and Boundaries
- The parser implements the documented grammar; it is not a general-purpose natural-language interpreter.
- Upstream 0.1.10 declares PostgreSQL 13–18 features and pins pgrx 0.18.1. Pigsty packages cover PostgreSQL 14–18 and apply a locked pgrx 0.19.1 compatibility update.
pg_whenis not relocatable and its control file requires a superuser forCREATE EXTENSION.- Invalid text raises an error. All five functions are
STRICT, so a null input returns null;nanos_at(text)also errors when the epoch nanoseconds cannot fit inbigint. - The 0.1.10 SQL functions are declared
IMMUTABLE, but relative expressions such asnow,tomorrow, and5 days agoread the wall clock. Do not use relative-input calls in expression indexes or generated columns, and do not rely on them being reevaluated in cached plans; only fully specified date, time, and time-zone inputs are time-independent.