Skip to content

Solar utils for PostgreSQL - Convert Gregorian to Solar Hijri date.

Notifications You must be signed in to change notification settings

MamarezaAlipour/Gregorian2Solar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shamsi Extension (A Solar utils for PostgreSQL)

Shamsi Ext is a package for converting Gregorian dates to Solar Hijri. This package consists of the following functions:

extensions

shamsi_format(TIMESTAMP WITH TIME ZONE, with_time BOOLEAN DEFAULT TRUE)
shamsi_format(DATE)
shamsi_part(TEXT, TIMESTAMP WITH TIME ZONE)
shamsi_part(TEXT, DATE)

Examples:

SELECT shamsi_format(now()); -->   1400/10/04 23:45:37
SELECT shamsi_format(now(), false); -->   1400/10/04
SELECT shamsi_format('2019-07-07', false); -->  1398/04/16
SELECT shamsi_format('2021-03-20'); -->  1399/12/30 00:00:00
SELECT shamsi_format('2021-03-20'::date); -->  1399/12/30
SELECT shamsi_part('year', '2019-07-07 14:10:52.84937+04:30'); --> 1398
SELECT shamsi_part('minute', '2019-07-07 14:10:52.84937+04:30'); --> 10
SELECT shamsi_part('doy', '2019-07-07 14:10:52.84937+04:30'); --> 109
SELECT shamsi_part('dow', '2019-07-07'); --> 4

shamsi_part function can accept these values as the first parameter:

  • year
  • month
  • day
  • hour
  • minute
  • second
  • doy (day of year)
  • dow (day of week with index zero as saturday)
  • quarter
  • decade
  • century

Installation

Dependencies:

sudo apt install postgresql-server-dev-14

Run make to build and install

make
sudo make install

Run this command in your psql shell:

\d your_db_name

> CREATE EXTENSION shamsi_ext;

Running tests

make installcheck

About

Solar utils for PostgreSQL - Convert Gregorian to Solar Hijri date.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published