Re: Dates BC. - Mailing list pgsql-hackers

From Karel Zak
Subject Re: Dates BC.
Date
Msg-id 20031219080415.GA24721@zf.jcu.cz
Whole thread Raw
In response to Dates BC.  (Kurt Roeckx <Q@ping.be>)
List pgsql-hackers
On Thu, Dec 18, 2003 at 02:11:20PM +0100, 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.
Is there connection between formatting.c and date_part() ? I don't think so...

> 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?
I think this code is OK, butg is somethere in extract (date_part) code.


test=# select to_date('0020-01-10 BC'::text, 'YYYY-MM-DD BC');   to_date    
---------------0020-01-10 BC
(1 řádka)

test=# select to_date('0020-01-10 AD'::text, 'YYYY-MM-DD BC'); to_date   
------------0020-01-10

test=# select to_char('0020-01-10 BC'::date, 'YYYY-MM-DD AD'); to_char    
---------------0020-01-10 BC       Karel
-- Karel Zak  <zakkr@zf.jcu.cz>http://home.zf.jcu.cz/~zakkr/


pgsql-hackers by date:

Previous
From: Chongbing Liu
Date:
Subject: How can I return a NULL value from a function?
Next
From: "Dann Corbit"
Date:
Subject: Re: Dates BC.