From: | Chapman Flack <chap(at)anastigmatix(dot)net> |
---|---|
To: | Yonatan Misgan <yonamis(at)dtu(dot)edu(dot)et>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Extension development |
Date: | 2019-08-15 22:55:12 |
Message-ID: | 5D55E2D0.4070602@anastigmatix.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 08/15/19 02:58, Yonatan Misgan wrote:
> 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.
I find myself wondering whether getting only the year is sufficient to
do the conversion. There is already an Ethiopic calendar available for
Java (not included, but in org.threeten.extra[1]), and it seems to say
the years do not align precisely with Gregorian years (as I would not
have expected anyway):
"Dates are aligned such that 0001-01-01 (Ethiopic) is 0008-08-27 (ISO)."
So it seems more likely that you would need a calculation involving the
year, month, and day ... or even that the Julian day number already
stored in PostgreSQL could be the most convenient starting point for
the arithmetic you need.
It's possible you might want to crib some of the algorithm from the
threeten-extra Ethiopic date sources [2]. It would need adjustment for
the PostgreSQL epoch being Gregorian year 2000 rather than Java's 1970
(a simple constant offset), and for PostgreSQL using a Julian day number
rather than java.time's proleptic Gregorian (a difference changing by three
days every 400 years).
Another option would be to take advantage of PL/Java and directly use
the threeten-extra Ethiopic calendar.
Regards,
-Chap
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Munro | 2019-08-15 23:46:43 | Re: Extension development |
Previous Message | Tomas Vondra | 2019-08-15 22:37:48 | Re: BF failure: could not open relation with OID XXXX while querying pg_views |