diff options
author | Bruce Momjian <bruce@momjian.us> | 2004-03-05 02:41:14 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2004-03-05 02:41:14 +0000 |
commit | 1973971821672447d30bda6f12736a7e5987569f (patch) | |
tree | 7c2ac97848f3cd1eb45442feceef2834c6b25581 /src/backend/utils/adt/timestamp.c | |
parent | 44611f6e6d2cd11ac2c6dc1f41c13a98ec633f08 (diff) |
Per a brief conversation with Tom, I've created a patch for adding
support for 'week' within the date_trunc function.
Within the patch I added a couple of test cases and associated target
output, and changed the documentation to add 'week' appropriately.
Robert Creager
Diffstat (limited to 'src/backend/utils/adt/timestamp.c')
-rw-r--r-- | src/backend/utils/adt/timestamp.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index ad79025ebc0..4fb5f743b03 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.99 2004/02/14 20:16:17 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.100 2004/03/05 02:41:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -2564,6 +2564,13 @@ timestamp_trunc(PG_FUNCTION_ARGS) 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: tm->tm_year = (tm->tm_year / 1000) * 1000; case DTK_CENTURY: @@ -2672,6 +2679,13 @@ timestamptz_trunc(PG_FUNCTION_ARGS) 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: tm->tm_year = (tm->tm_year / 1000) * 1000; case DTK_CENTURY: |