Skip to content

Commit c584103

Browse files
committed
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).
1 parent 19dacd4 commit c584103

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/backend/utils/adt/timestamp.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.114 2004/11/01 22:00:30 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.115 2004/11/20 22:12:44 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -3534,7 +3534,11 @@ timestamptz_part(PG_FUNCTION_ARGS)
35343534
break;
35353535

35363536
case DTK_YEAR:
3537-
result = tm->tm_year;
3537+
if (tm->tm_year > 0)
3538+
result = tm->tm_year;
3539+
else
3540+
/* there is no year 0, just 1 BC and 1 AD */
3541+
result = tm->tm_year - 1;
35383542
break;
35393543

35403544
case DTK_DECADE:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy