pg_bikram_sambat
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_bikram_sambat | 0.1.0 | TYPE | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 3860 | pg_bikram_sambat | No | Yes | No | Yes | No | Yes | - |
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.1.0 | 1817161514 | pg_bikram_sambat | - |
| RPM | PIGSTY | 0.1.0 | 1817161514 | pg_bikram_sambat_$v | - |
| DEB | PIGSTY | 0.1.0 | 1817161514 | postgresql-$v-pg-bikram-sambat | - |
Build
You can build the RPM / DEB packages for pg_bikram_sambat using pig build:
Install
You can install pg_bikram_sambat directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Create Extension:
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.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)