#include "pg_bikram_sambat.h" PG_FUNCTION_INFO_V1(bs_date_in); Datum bs_date_in(PG_FUNCTION_ARGS) { char *str = PG_GETARG_CSTRING(0); PG_RETURN_INT32(parse_bs_date_internal(str)); } PG_FUNCTION_INFO_V1(bs_date_out); Datum bs_date_out(PG_FUNCTION_ARGS) { BSDateADT date = PG_GETARG_INT32(0); int year, month, day; DateParts bsDate; char *result; int jd = date + POSTGRES_EPOCH_JDATE; j2date(jd, &year, &month, &day); bsDate = adToBs(year, month, day); result = psprintf("%04d-%02d-%02d", bsDate.year, bsDate.month, bsDate.day); PG_RETURN_CSTRING(result); }