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: [email protected]<mailto:[email protected]>
[email protected]<mailto:[email protected]>
Tel: (+251)-911180185 (mob)