pg_bikram_sambat
pg_bikram_sambat : Bikram Sambat date type and AD/BS conversion functions
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 3860 | pg_bikram_sambat | pg_bikram_sambat | 0.1.0 |
TYPE | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --s-d-r | No | Yes | No | Yes | yes | no |
| Relationships | |
|---|---|
| See Also | pgcalendar pg_rrule pg_duration timestamp9 pg_when cron_utils pg_cron |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.1.0 |
18 17 16 15 14 | pg_bikram_sambat |
- |
| RPM | PIGSTY | 0.1.0 |
18 17 16 15 14 | pg_bikram_sambat_$v |
- |
| DEB | PIGSTY | 0.1.0 |
18 17 16 15 14 | postgresql-$v-pg-bikram-sambat |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| el8.aarch64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| el9.x86_64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| el9.aarch64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| el10.x86_64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| el10.aarch64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| d12.x86_64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| d12.aarch64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| d13.x86_64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| d13.aarch64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| u22.x86_64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| u22.aarch64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| u24.x86_64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| u24.aarch64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| u26.x86_64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| u26.aarch64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
Source
github.com/LeohangRai/pg_bikram_sambat
pg_bikram_sambat-0.1.0.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Create this extension with:
Usage
Sources: PGXN metadata, PGXN source tree, type SQL, function SQL, operator SQL, cast SQL, regression examples, TODO
pg_bikram_sambat adds a bs_date type for Bikram Sambat dates plus conversion, formatting, comparison, and btree indexing support. Install it as a normal PostgreSQL extension:
Date Type
bs_date stores a Bikram Sambat date and displays it as YYYY-MM-DD. Text input accepts year/month/day values separated with /, -, or .; the input parser also accepts day-first strings when the year appears in the last field.
Use it in tables like any other PostgreSQL type:
Conversion Functions
ad_to_bs(date) converts a Gregorian date to bs_date:
current_bs_date() returns the current transaction timestamp converted to bs_date, so repeated calls inside the same transaction are stable:
Version 0.1.0 does not expose a SQL bs_to_ad() function or direct bs_date to date cast; the upstream TODO file lists those as future work.
Formatting
The extension overloads PostgreSQL to_char for bs_date:
Supported date-format tokens are YYYY, YY, Month, Mon, MM, Day, Dy, and DD. Month and weekday names follow the casing of the format token, so MONTH, Month, and month produce upper-case, title-case, and lower-case English names.
Pass dev as the third argument for Devanagari digits, month names, and weekday names:
Operators And Indexes
bs_date supports the comparison operators =, <>, >, >=, <, and <=. The default btree operator class bs_date_ops enables ordinary btree indexes, range predicates, and ordering:
Caveats
The packaged conversion dataset covers BS years 2000 through 2100, with 1943-04-14 AD as the reference date for 2000-01-01 BS. Dates before the reference date or beyond the mapped BS range raise PostgreSQL errors. The extension defines an implicit cast from text to bs_date, but it does not define casts from arbitrary numeric types.