Re: Dates BC.

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Kurt Roeckx <Q(at)ping(dot)be>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Dates BC.
Date: 2003-12-18 13:45:33
Message-ID: 200312181345.hBIDjXH04946@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Kurt Roeckx wrote:
> I find this a little strange:
>
> select date_part('year', '0002-01-01 BC'::date);
> date_part
> -----------
> -1
>
> It seems 1 BC and 0 are the same year.
>
> In backend/utils/adt/formatting.c:
>
> if (tmfc.bc)
> {
> if (tm->tm_year > 0)
> tm->tm_year = -(tm->tm_year - 1);
>
> It this normal or a bug?

Uh, well, yea, there was no year 0. However, it seems we should return
the proper year. My guess is that missing year 0 is the cause, and
there are certain reasons year 2 BC should return -1. If you are
subtracting dates, like 32AD - 4BC, you get 35, which is the proper
number of years spanned.

I am not sure what is the proper answer. I thought date_part just
grabbed "parts of the date" like it says, but obviously not, and there
are some good reasons for it, I guess.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

  • Dates BC. at 2003-12-18 13:11:20 from Kurt Roeckx

Browse pgsql-hackers by date

  From Date Subject
Next Message ohp 2003-12-18 14:07:16 Re: TODO list
Previous Message Bruce Momjian 2003-12-18 13:40:58 Re: ecpg tests compile failure