Index: src/backend/utils/adt/timestamp.c =================================================================== RCS file: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v retrieving revision 1.117 diff -c -c -r1.117 timestamp.c *** src/backend/utils/adt/timestamp.c 31 Dec 2004 22:01:22 -0000 1.117 --- src/backend/utils/adt/timestamp.c 28 Mar 2005 21:59:22 -0000 *************** *** 2754,2765 **** switch (val) { case DTK_WEEK: ! isoweek2date(date2isoweek(tm->tm_year, tm->tm_mon, tm->tm_mday), &(tm->tm_year), &(tm->tm_mon), &(tm->tm_mday)); tm->tm_hour = 0; tm->tm_min = 0; tm->tm_sec = 0; fsec = 0; break; case DTK_MILLENNIUM: /* see comments in timestamptz_trunc */ if (tm->tm_year > 0) --- 2754,2776 ---- switch (val) { case DTK_WEEK: ! { ! int woy; ! ! woy = date2isoweek(tm->tm_year, tm->tm_mon, tm->tm_mday); ! /* ! * If it is the 53rd week and the month is January, ! * then the week must belong to the previous year. ! */ ! if (woy >= 53 && tm->tm_mon == 1) ! --tm->tm_year; ! isoweek2date(woy, &(tm->tm_year), &(tm->tm_mon), &(tm->tm_mday)); tm->tm_hour = 0; tm->tm_min = 0; tm->tm_sec = 0; fsec = 0; break; + } case DTK_MILLENNIUM: /* see comments in timestamptz_trunc */ if (tm->tm_year > 0) *************** *** 2874,2886 **** switch (val) { case DTK_WEEK: ! isoweek2date(date2isoweek(tm->tm_year, tm->tm_mon, tm->tm_mday), &(tm->tm_year), &(tm->tm_mon), &(tm->tm_mday)); tm->tm_hour = 0; tm->tm_min = 0; tm->tm_sec = 0; fsec = 0; redotz = true; break; /* one may consider DTK_THOUSAND and DTK_HUNDRED... */ case DTK_MILLENNIUM: --- 2885,2908 ---- switch (val) { case DTK_WEEK: ! { ! int woy; ! ! woy = date2isoweek(tm->tm_year, tm->tm_mon, tm->tm_mday); ! /* ! * If it is the 53rd week and the month is January, ! * then the week must belong to the previous year. ! */ ! if (woy >= 53 && tm->tm_mon == 1) ! --tm->tm_year; ! isoweek2date(woy, &(tm->tm_year), &(tm->tm_mon), &(tm->tm_mday)); tm->tm_hour = 0; tm->tm_min = 0; tm->tm_sec = 0; fsec = 0; redotz = true; break; + } /* one may consider DTK_THOUSAND and DTK_HUNDRED... */ case DTK_MILLENNIUM: