1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-22 17:42:17 +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

@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------
* formatting.c
*
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.72 2004/01/07 18:56:28 neilc Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.73 2004/03/30 15:53:18 momjian Exp $
*
*
* Portions Copyright (c) 1999-2003, PostgreSQL Global Development Group
@@ -169,7 +169,7 @@ static char *months_full[] = {
* AC / DC
* ----------
*/
#define YEAR_ABS(_y) (_y < 0 ? -(_y -1) : _y)
#define YEAR_ABS(_y) (_y <= 0 ? -(_y -1) : _y)
#define BC_STR_ORIG " BC"
#define A_D_STR "A.D."
@@ -2119,7 +2119,7 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
case DCH_B_C:
if (flag == TO_CHAR)
{
strcpy(inout, (tm->tm_year < 0 ? B_C_STR : A_D_STR));
strcpy(inout, (tm->tm_year <= 0 ? B_C_STR : A_D_STR));
return 3;
}
@@ -2134,7 +2134,7 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
case DCH_BC:
if (flag == TO_CHAR)
{
strcpy(inout, (tm->tm_year < 0 ? BC_STR : AD_STR));
strcpy(inout, (tm->tm_year <= 0 ? BC_STR : AD_STR));
return 1;
}
@@ -2149,7 +2149,7 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
case DCH_b_c:
if (flag == TO_CHAR)
{
strcpy(inout, (tm->tm_year < 0 ? b_c_STR : a_d_STR));
strcpy(inout, (tm->tm_year <= 0 ? b_c_STR : a_d_STR));
return 3;
}
@@ -2164,7 +2164,7 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
case DCH_bc:
if (flag == TO_CHAR)
{
strcpy(inout, (tm->tm_year < 0 ? bc_STR : ad_STR));
strcpy(inout, (tm->tm_year <= 0 ? bc_STR : ad_STR));
return 1;
}