Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit191ef2b

Browse files
committed
Change EXTRACT(EPOCH FROM timestamp) so that a timestamp without time zone
is assumed to be in local time, not GMT. This improves consistency withother operations, which all assume local timezone when it matters. Perbug #897.
1 parent3d1a1e8 commit191ef2b

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

‎src/backend/utils/adt/timestamp.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* 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 $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2865,13 +2865,26 @@ timestamp_part(PG_FUNCTION_ARGS)
28652865
switch (val)
28662866
{
28672867
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,&timestamptz)!=0)
2879+
elog(ERROR,"Unable to convert TIMESTAMP to TIMESTAMP WITH TIME ZONE");
2880+
28682881
#ifdefHAVE_INT64_TIMESTAMP
2869-
result= ((timestamp-SetEpochTimestamp()) /1000000e0);
2882+
result= ((timestamptz-SetEpochTimestamp()) /1000000e0);
28702883
#else
2871-
result=timestamp-SetEpochTimestamp();
2884+
result=timestamptz-SetEpochTimestamp();
28722885
#endif
28732886
break;
2874-
2887+
}
28752888
caseDTK_DOW:
28762889
if (timestamp2tm(timestamp,NULL,tm,&fsec,NULL)!=0)
28772890
elog(ERROR,"Unable to encode TIMESTAMP");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp