aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/timestamp.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-11-20 22:12:44 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-11-20 22:12:44 +0000
commitc584103f56040f1c3d2d125256b005ff09c4d94e (patch)
tree079b073b0dbe24bd09106ecb6e79ab21c189bed5 /src/backend/utils/adt/timestamp.c
parent19dacd44929ae2679ffb708a2386f708b70da11f (diff)
downloadpostgresql-c584103f56040f1c3d2d125256b005ff09c4d94e.tar.gz
postgresql-c584103f56040f1c3d2d125256b005ff09c4d94e.zip
Patch of 2004-03-30 corrected date_part(timestamp) for extracting
the year from a BC date, but failed to make the same fix in date_part(timestamptz).
Diffstat (limited to 'src/backend/utils/adt/timestamp.c')
-rw-r--r--src/backend/utils/adt/timestamp.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index 0b7190c3455..e8bc4630021 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.114 2004/11/01 22:00:30 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.115 2004/11/20 22:12:44 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -3534,7 +3534,11 @@ timestamptz_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: