|
8 | 8 | * |
9 | 9 | * |
10 | 10 | * IDENTIFICATION |
11 | | - * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.78 2003/02/22 05:57:45 tgl Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.79 2003/02/27 21:36:58 tgl Exp $ |
12 | 12 | * |
13 | 13 | *------------------------------------------------------------------------- |
14 | 14 | */ |
@@ -2865,13 +2865,26 @@ timestamp_part(PG_FUNCTION_ARGS) |
2865 | 2865 | switch (val) |
2866 | 2866 | { |
2867 | 2867 | caseDTK_EPOCH: |
| 2868 | +{ |
| 2869 | +inttz; |
| 2870 | +TimestampTztimestamptz; |
| 2871 | + |
| 2872 | +/* convert to timestamptz to produce consistent results */ |
| 2873 | +if (timestamp2tm(timestamp,NULL,tm,&fsec,NULL)!=0) |
| 2874 | +elog(ERROR,"Unable to convert TIMESTAMP to TIMESTAMP WITH TIME ZONE (tm)"); |
| 2875 | + |
| 2876 | +tz=DetermineLocalTimeZone(tm); |
| 2877 | + |
| 2878 | +if (tm2timestamp(tm,fsec,&tz,×tamptz)!=0) |
| 2879 | +elog(ERROR,"Unable to convert TIMESTAMP to TIMESTAMP WITH TIME ZONE"); |
| 2880 | + |
2868 | 2881 | #ifdefHAVE_INT64_TIMESTAMP |
2869 | | -result= ((timestamp-SetEpochTimestamp()) /1000000e0); |
| 2882 | +result= ((timestamptz-SetEpochTimestamp()) /1000000e0); |
2870 | 2883 | #else |
2871 | | -result=timestamp-SetEpochTimestamp(); |
| 2884 | +result=timestamptz-SetEpochTimestamp(); |
2872 | 2885 | #endif |
2873 | 2886 | break; |
2874 | | - |
| 2887 | +} |
2875 | 2888 | caseDTK_DOW: |
2876 | 2889 | if (timestamp2tm(timestamp,NULL,tm,&fsec,NULL)!=0) |
2877 | 2890 | elog(ERROR,"Unable to encode TIMESTAMP"); |
|