Re: Julian Day 0 question

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Chernow <ac(at)esilo(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Julian Day 0 question
Date: 2007-12-15 00:19:43
Message-ID: 15646.1197677983@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Andrew Chernow <ac(at)esilo(dot)com> writes:
> Looks like a difference in calendars: I think the docs give the starting
> date in Julian proleptic Calendar while to_char returns Gregorian
> proleptic Calendar.

Yeah. We're definitely using Gregorian counting, because we're omitting
leap years at multiples of 400 years:

regression=# select 'J114417'::date;
date
---------------
4400-02-28 BC
(1 row)

regression=# select 'J114418'::date;
date
---------------
4400-03-01 BC
(1 row)

So as far as that goes, I'm inclined to leave the code alone and adjust
the docs.

The regular date input routine hasn't got a problem with J0:

regression=# select 'J1'::date;
date
---------------
4714-11-25 BC
(1 row)

regression=# select 'J0'::date;
date
---------------
4714-11-24 BC
(1 row)

so to_date's behavior in the case seems a bit broken, but I'm not sure
if it's worth fixing. IIRC that code uses zero to mean "field not
entered", so it'd need some ugly hack to handle this.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2007-12-15 02:46:17 Re: mssql migration and boolean to integer problems
Previous Message Tom Lane 2007-12-14 23:12:00 Re: postgres writer process growing up too much