1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-16 06:01:02 +03:00

Fix to_char for 1 BC. Previously it returned 1 AD.

Fix to_char(year) for BC dates.  Previously it returned one less than
the current year.

Add documentation mentioning that there is no 0 AD.
This commit is contained in:
Bruce Momjian
2004-03-30 15:53:18 +00:00
parent f2c064afcb
commit fd071bd478
4 changed files with 19 additions and 15 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.102 2004/03/22 01:38:17 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.103 2004/03/30 15:53:18 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -3261,7 +3261,11 @@ timestamp_part(PG_FUNCTION_ARGS)
break;
case DTK_YEAR:
result = tm->tm_year;
if (tm->tm_year > 0)
result = tm->tm_year;
else
/* there is no year 0, just 1 BC and 1 AD*/
result = tm->tm_year - 1;
break;
case DTK_DECADE: