Re: Dates BC.

From: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
To: Dann Corbit <DCorbit(at)connx(dot)com>
Cc: Kurt Roeckx <Q(at)ping(dot)be>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Dates BC.
Date: 2003-12-19 10:22:03
Message-ID: 20031219102203.GE24721@zf.jcu.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

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() there
Kurt 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 next
examples 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(at)zf(dot)jcu(dot)cz>
http://home.zf.jcu.cz/~zakkr/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Sabino Mullane 2003-12-19 12:07:57 Re: PostgreSQL speakers needed for OSCON 2004
Previous Message Dann Corbit 2003-12-19 09:12:08 Re: Dates BC.

Browse pgsql-patches by date

  From Date Subject
Next Message Peter Eisentraut 2003-12-19 14:23:48 Re: [GENERAL] restore error - language "plperlu" is not trusted
Previous Message Dann Corbit 2003-12-19 09:12:08 Re: Dates BC.