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:
@ -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:
|
||||
|
Reference in New Issue
Block a user