Re: Dates BC. - Mailing list pgsql-hackers

From Karel Zak
Subject Re: Dates BC.
Date
Msg-id 20031219102203.GE24721@zf.jcu.cz
Whole thread Raw
In response to Re: Dates BC.  ("Dann Corbit" <DCorbit@connx.com>)
Responses Re: Dates BC.
List pgsql-hackers
On Fri, Dec 19, 2003 at 01:12:08AM -0800, Dann Corbit wrote:
> There is no zero calendar year.  The first year of Anno Domini is 1.  It's ordinal, not cardinal.
I agree. But  the follow quoted  code is  not use in  date_part() thereKurt  found bug. It's  used  in to_timestamp()
_only_, and it  works,because tm2timestamp() and date2j() work with zero 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);                           
... "tm->tm_year = -(tm->tm_year - 1)" is used for:

# select to_timestamp('0001/01/01 BC', 'YYYY/MM/DD AD');    to_timestamp      
------------------------0001-01-01 00:00:00 BC      and it's OK.

I  think a  bug  is  somewhere in  timestamp2tm()  which  used in  nextexamples and it's shared between more
functions:

# select to_char('0001-01-01 BC'::date, 'YYYY/MM/DD AD');   to_char    ---------------0000/01/01 AD

# SELECT EXTRACT(YEAR from '0001-01-01 BC'::date);date_part -----------        0          
   Karel


-- Karel Zak  <zakkr@zf.jcu.cz>http://home.zf.jcu.cz/~zakkr/


pgsql-hackers by date:

Previous
From: "Dann Corbit"
Date:
Subject: Re: Dates BC.
Next
From: Peter Eisentraut
Date:
Subject: Linking with -lc not a good idea