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

Commit2610265

Browse files
committed
Fix AT TIME ZONE for timestamps without time zones:
test=> select ('2005-07-20 00:00:00'::timestamp without time zone) attime zone 'Europe/Paris'; timezone------------------------ 2005-07-19 22:00:00-04Udpate documentation.
1 parent4749e91 commit2610265

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.268 2005/07/2016:42:29 momjian Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.269 2005/07/22 21:16:14 momjian Exp $
33
PostgreSQL documentation
44
-->
55

@@ -5693,23 +5693,23 @@ SELECT date_trunc('year', TIMESTAMP '2001-02-16 20:38:40');
56935693
<literal><type>timestamp without time zone</type> AT TIME ZONE <replaceable>zone</></literal>
56945694
</entry>
56955695
<entry><type>timestamp with time zone</type></entry>
5696-
<entry>Convert localtime ingiventime zone to UTC</entry>
5696+
<entry>Treat given timestamp <emphasis>withouttimezone</> as locatedinthe specifiedtime zone</entry>
56975697
</row>
56985698

56995699
<row>
57005700
<entry>
57015701
<literal><type>timestamp with time zone</type> AT TIME ZONE <replaceable>zone</></literal>
57025702
</entry>
57035703
<entry><type>timestamp without time zone</type></entry>
5704-
<entry>ConvertUTC to local timein given time zone</entry>
5704+
<entry>Convertgiven timestamp <emphasis>with timezone</> to the new time zone</entry>
57055705
</row>
57065706

57075707
<row>
57085708
<entry>
57095709
<literal><type>time with time zone</type> AT TIME ZONE <replaceable>zone</></literal>
57105710
</entry>
57115711
<entry><type>time with time zone</type></entry>
5712-
<entry>Convertlocal timeacross timezones</entry>
5712+
<entry>Convertgiven time<emphasis>with timezone</> to the new time zone</entry>
57135713
</row>
57145714
</tbody>
57155715
</tgroup>
@@ -5720,7 +5720,8 @@ SELECT date_trunc('year', TIMESTAMP '2001-02-16 20:38:40');
57205720
specified either as a text string (e.g., <literal>'PST'</literal>)
57215721
or as an interval (e.g., <literal>INTERVAL '-08:00'</literal>).
57225722
In the text case, the available zone names are those shown in
5723-
<xref linkend="datetime-timezone-set-table">.
5723+
<xref linkend="datetime-timezone-set-table">. The time zone can
5724+
also be implied using the default time zone for that session.
57245725
</para>
57255726

57265727
<para>
@@ -5732,10 +5733,9 @@ SELECT TIMESTAMP '2001-02-16 20:38:40' AT TIME ZONE 'MST';
57325733
SELECT TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-05' AT TIME ZONE 'MST';
57335734
<lineannotation>Result: </lineannotation><computeroutput>2001-02-16 18:38:40</computeroutput>
57345735
</screen>
5735-
The first example takes a zone-less time stamp and interprets it as MST time
5736-
(UTC-7) to produce a UTC time stamp, which is then rotated to PST (UTC-8)
5737-
for display. The second example takes a time stamp specified in EST
5738-
(UTC-5) and converts it to local time in MST (UTC-7).
5736+
The first example takes a time stamp without time zone and interprets it as MST time
5737+
(UTC-7), which is then converted to PST (UTC-8) for display. The second example takes
5738+
a time stamp specified in EST (UTC-5) and converts it to local time in MST (UTC-7).
57395739
</para>
57405740

57415741
<para>

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.141 2005/07/2219:00:54 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.142 2005/07/2221:16:15 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1035,7 +1035,7 @@ timestamp2tm(Timestamp dt, int *tzp, struct pg_tm *tm, fsec_t *fsec, char **tzn,
10351035
#endif
10361036

10371037
/* add offset to go from J2000 back to standard Julian date */
1038-
date+=POSTGRES_EPOCH_JDATE;
1038+
date+=POSTGRES_EPOCH_JDATE;
10391039

10401040
/* Julian day routine does not work for negative Julian days */
10411041
if (date<0||date>(Timestamp)INT_MAX)
@@ -1147,8 +1147,8 @@ tm2timestamp(struct pg_tm *tm, fsec_t fsec, int *tzp, Timestamp *result)
11471147
return-1;
11481148

11491149
date=date2j(tm->tm_year,tm->tm_mon,tm->tm_mday)-POSTGRES_EPOCH_JDATE;
1150-
11511150
time=time2t(tm->tm_hour,tm->tm_min,tm->tm_sec,fsec);
1151+
11521152
#ifdefHAVE_INT64_TIMESTAMP
11531153
*result=date*USECS_PER_DAY+time;
11541154
/* check for major overflow */
@@ -2673,7 +2673,7 @@ timestamp_text(PG_FUNCTION_ARGS)
26732673
result=palloc(len);
26742674

26752675
VARATT_SIZEP(result)=len;
2676-
memmove(VARDATA(result),str,(len-VARHDRSZ));
2676+
memmove(VARDATA(result),str,len-VARHDRSZ);
26772677

26782678
pfree(str);
26792679

@@ -2704,7 +2704,7 @@ text_timestamp(PG_FUNCTION_ARGS)
27042704

27052705
sp=VARDATA(str);
27062706
dp=dstr;
2707-
for (i=0;i<(VARSIZE(str)-VARHDRSZ);i++)
2707+
for (i=0;i<VARSIZE(str)-VARHDRSZ;i++)
27082708
*dp++=*sp++;
27092709
*dp='\0';
27102710

@@ -2729,12 +2729,12 @@ timestamptz_text(PG_FUNCTION_ARGS)
27292729

27302730
str=DatumGetCString(DirectFunctionCall1(timestamptz_out,timestamp));
27312731

2732-
len=(strlen(str)+VARHDRSZ);
2732+
len=strlen(str)+VARHDRSZ;
27332733

27342734
result=palloc(len);
27352735

27362736
VARATT_SIZEP(result)=len;
2737-
memmove(VARDATA(result),str,(len-VARHDRSZ));
2737+
memmove(VARDATA(result),str,len-VARHDRSZ);
27382738

27392739
pfree(str);
27402740

@@ -2764,7 +2764,7 @@ text_timestamptz(PG_FUNCTION_ARGS)
27642764

27652765
sp=VARDATA(str);
27662766
dp=dstr;
2767-
for (i=0;i<(VARSIZE(str)-VARHDRSZ);i++)
2767+
for (i=0;i<VARSIZE(str)-VARHDRSZ;i++)
27682768
*dp++=*sp++;
27692769
*dp='\0';
27702770

@@ -2789,7 +2789,7 @@ interval_text(PG_FUNCTION_ARGS)
27892789
str=DatumGetCString(DirectFunctionCall1(interval_out,
27902790
IntervalPGetDatum(interval)));
27912791

2792-
len=(strlen(str)+VARHDRSZ);
2792+
len=strlen(str)+VARHDRSZ;
27932793

27942794
result=palloc(len);
27952795

@@ -3084,7 +3084,7 @@ timestamptz_trunc(PG_FUNCTION_ARGS)
30843084

30853085
caseDTK_MILLISEC:
30863086
#ifdefHAVE_INT64_TIMESTAMP
3087-
fsec= ((fsec /1000)*1000);
3087+
fsec= (fsec /1000)*1000;
30883088
#else
30893089
fsec=rint(fsec*1000) /1000;
30903090
#endif
@@ -3181,7 +3181,7 @@ interval_trunc(PG_FUNCTION_ARGS)
31813181

31823182
caseDTK_MILLISEC:
31833183
#ifdefHAVE_INT64_TIMESTAMP
3184-
fsec= ((fsec /1000)*1000);
3184+
fsec= (fsec /1000)*1000;
31853185
#else
31863186
fsec=rint(fsec*1000) /1000;
31873187
#endif
@@ -3932,7 +3932,7 @@ timestamp_zone(PG_FUNCTION_ARGS)
39323932
{
39333933
text*zone=PG_GETARG_TEXT_P(0);
39343934
Timestamptimestamp=PG_GETARG_TIMESTAMP(1);
3935-
Timestampresult;
3935+
TimestampTzresult;
39363936
inttz;
39373937
pg_tz*tzp;
39383938
chartzname[TZ_STRLEN_MAX+1];
@@ -3968,7 +3968,7 @@ timestamp_zone(PG_FUNCTION_ARGS)
39683968
tzname)));
39693969
PG_RETURN_NULL();
39703970
}
3971-
PG_RETURN_TIMESTAMPTZ(timestamp2timestamptz(result));
3971+
PG_RETURN_TIMESTAMPTZ(result);
39723972
}
39733973

39743974
/* timestamp_izone()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp