From: | Yonatan Misgan <yonamis(at)dtu(dot)edu(dot)et> |
---|---|
To: | "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Extension development |
Date: | 2019-08-15 06:58:07 |
Message-ID: | AM0PR10MB302727F3A41A542A1AD4936B94AC0@AM0PR10MB3027.EURPRD10.PROD.OUTLOOK.COM |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello, I am trying to develop calendar extension for PostgreSQL but there is a difficulties on how to get day, month and year from PostgreSQL source code because when am read the PostgreSQL source code it uses DateADT as a data type and this DateADT returns the total numbers of day. So how can I get day, month or year only. For example the below code is PostgreSQL source code to return current date.
/*
* GetSQLCurrentDate -- implements CURRENT_DATE
*/
DateADT
GetSQLCurrentDate(void)
{
TimestampTz ts;
struct pg_tm tt,
*tm = &tt;
fsec_t fsec;
int tz;
ts = GetCurrentTransactionStartTimestamp();
if (timestamp2tm(ts, &tz, tm, &fsec, NULL, NULL) != 0)
ereport(ERROR,
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
errmsg("timestamp out of range")));
return date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - POSTGRES_EPOCH_JDATE;
}
From this source code how can I get only the year to convert my own calendar year. I need this because Ethiopian calendar is totally differ from GC in terms of day, month and year.
Regards,
____________________________________
Yonathan Misgan
Assistant Lecturer, @ Debre Tabor University
Faculty of Technology
Department of Computer Science
Studying MSc in Computer Science (in Data and Web Engineering)
@ Addis Ababa University
E-mail: yonamis(at)dtu(dot)edu(dot)et<mailto:yonamis(at)dtu(dot)edu(dot)et>
yonathanmisgan(dot)4(at)gmail(dot)com<mailto:yonathanmisgan(dot)4(at)gmail(dot)com>
Tel: (+251)-911180185 (mob)
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Munro | 2019-08-15 07:17:49 | Re: Why is infinite_recurse test suddenly failing? |
Previous Message | Tom Lane | 2019-08-15 05:49:19 | Re: Why is infinite_recurse test suddenly failing? |