|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.128 2005/06/30 03:48:58 neilc Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.129 2005/07/04 14:38:31 momjian Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -2793,9 +2793,12 @@ timestamp_trunc(PG_FUNCTION_ARGS)
|
2793 | 2793 | /*
|
2794 | 2794 | *If it is week 52/53 and the month is January,
|
2795 | 2795 | *then the week must belong to the previous year.
|
| 2796 | + *Also, some December dates belong to the next year. |
2796 | 2797 | */
|
2797 | 2798 | if (woy >=52&&tm->tm_mon==1)
|
2798 | 2799 | --tm->tm_year;
|
| 2800 | +if (woy <=1&&tm->tm_mon==12) |
| 2801 | +++tm->tm_year; |
2799 | 2802 | isoweek2date(woy,&(tm->tm_year),&(tm->tm_mon),&(tm->tm_mday));
|
2800 | 2803 | tm->tm_hour=0;
|
2801 | 2804 | tm->tm_min=0;
|
@@ -2924,9 +2927,12 @@ timestamptz_trunc(PG_FUNCTION_ARGS)
|
2924 | 2927 | /*
|
2925 | 2928 | *If it is week 52/53 and the month is January,
|
2926 | 2929 | *then the week must belong to the previous year.
|
| 2930 | + *Also, some December dates belong to the next year. |
2927 | 2931 | */
|
2928 | 2932 | if (woy >=52&&tm->tm_mon==1)
|
2929 | 2933 | --tm->tm_year;
|
| 2934 | +if (woy <=1&&tm->tm_mon==12) |
| 2935 | +++tm->tm_year; |
2930 | 2936 | isoweek2date(woy,&(tm->tm_year),&(tm->tm_mon),&(tm->tm_mday));
|
2931 | 2937 | tm->tm_hour=0;
|
2932 | 2938 | tm->tm_min=0;
|
|