Extension development

Поиск
Список
Период
Сортировка
От Yonatan Misgan
Тема Extension development
Дата
Msg-id AM0PR10MB302727F3A41A542A1AD4936B94AC0@AM0PR10MB3027.EURPRD10.PROD.OUTLOOK.COM
обсуждение исходный текст
Ответы Re: Extension development  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Re: Extension development  (Chapman Flack <chap@anastigmatix.net>)
Список 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@dtu.edu.et

        yonathanmisgan.4@gmail.com

Tel:   (+251)-911180185 (mob)

 

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Why is infinite_recurse test suddenly failing?
Следующее
От: Thomas Munro
Дата:
Сообщение: Re: Why is infinite_recurse test suddenly failing?