pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #14660: Conversion to UTC not properly computed
3+ messages / 3 participants
[nested] [flat]
* BUG #14660: Conversion to UTC not properly computed
@ 2017-05-18 16:09 tbrandys@webcellence.com
2017-05-18 16:24 ` Re: BUG #14660: Conversion to UTC not properly computed Marko Tiikkaja <marko@joh.to>
2017-05-18 16:24 ` Re: BUG #14660: Conversion to UTC not properly computed Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 3+ messages in thread
From: tbrandys@webcellence.com @ 2017-05-18 16:09 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 14660
Logged by: Todd Brandys
Email address: tbrandys@webcellence.com
PostgreSQL version: 9.6.3
Operating system: Slackware Linux
Description:
According to
https://www.postgresql.org/docs/9.6/static/datatype-datetime.html
Conversions between timestamp without time zone and timestamp with time zone
normally assume that the timestamp without time zone value should be taken
or given as timezone local time. A different time zone can be specified for
the conversion using AT TIME ZONE.
With this in mind, the following output is troublesome:
vendita=# select now()::timestamp(0), now()::timestamp(0) with time zone,
timezone('utc', now()::timestamp(0)), timezone('utc', now()::timestamp(0)
with time zone);
now | now | timezone |
timezone
---------------------+------------------------+------------------------+---------------------
2017-05-18 08:55:10 | 2017-05-18 08:55:10-07 | 2017-05-18 01:55:10-07 |
2017-05-18 15:55:10
(1 row)
vendita=# show timezone;
TimeZone
------------
US/Arizona
(1 row)
The computation where the assumed use of the local time zone should occur is
incorrect (the third column).
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #14660: Conversion to UTC not properly computed
2017-05-18 16:09 BUG #14660: Conversion to UTC not properly computed tbrandys@webcellence.com
@ 2017-05-18 16:24 ` Marko Tiikkaja <marko@joh.to>
1 sibling, 0 replies; 3+ messages in thread
From: Marko Tiikkaja @ 2017-05-18 16:24 UTC (permalink / raw)
To: tbrandys@webcellence.com; +Cc: pgsql-bugs
On Thu, May 18, 2017 at 6:09 PM, <tbrandys@webcellence.com> wrote:
> The following bug has been logged on the website:
>
> Bug reference: 14660
> Logged by: Todd Brandys
> Email address: tbrandys@webcellence.com
> PostgreSQL version: 9.6.3
> Operating system: Slackware Linux
> Description:
>
> According to
> https://www.postgresql.org/docs/9.6/static/datatype-datetime.html
>
> Conversions between timestamp without time zone and timestamp with time
> zone
> normally assume that the timestamp without time zone value should be taken
> or given as timezone local time. A different time zone can be specified for
> the conversion using AT TIME ZONE.
>
> With this in mind, the following output is troublesome:
>
> vendita=# select now()::timestamp(0), now()::timestamp(0) with time zone,
> timezone('utc', now()::timestamp(0)), timezone('utc', now()::timestamp(0)
> with time zone);
> now | now | timezone |
> timezone
> ---------------------+------------------------+-------------
> -----------+---------------------
> 2017-05-18 08:55:10 | 2017-05-18 08:55:10-07 | 2017-05-18 01:55:10-07 |
> 2017-05-18 15:55:10
> (1 row)
>
> vendita=# show timezone;
> TimeZone
> ------------
> US/Arizona
> (1 row)
>
> The computation where the assumed use of the local time zone should occur
> is
> incorrect (the third column).
Looks fine to me. What should the answer in your opinion be, and why?
.m
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #14660: Conversion to UTC not properly computed
2017-05-18 16:09 BUG #14660: Conversion to UTC not properly computed tbrandys@webcellence.com
@ 2017-05-18 16:24 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 3+ messages in thread
From: Tom Lane @ 2017-05-18 16:24 UTC (permalink / raw)
To: tbrandys@webcellence.com; +Cc: pgsql-bugs
tbrandys@webcellence.com writes:
> vendita=# select now()::timestamp(0), now()::timestamp(0) with time zone,
> timezone('utc', now()::timestamp(0)), timezone('utc', now()::timestamp(0)
> with time zone);
> now | now | timezone |
> timezone
> ---------------------+------------------------+------------------------+---------------------
> 2017-05-18 08:55:10 | 2017-05-18 08:55:10-07 | 2017-05-18 01:55:10-07 |
> 2017-05-18 15:55:10
> (1 row)
> vendita=# show timezone;
> TimeZone
> ------------
> US/Arizona
> (1 row)
> The computation where the assumed use of the local time zone should occur is
> incorrect (the third column).
Looks fine to me. As per your first column, the result of now()::timestamp(0)
is '2017-05-18 08:55:10' (with no zone implied). timezone('utc', ...)
converts that into a timestamptz assuming that it's UTC, that is the value
is effectively '2017-05-18 08:55:10+00'. However, the timestamptz output
function rotates that back to the current TimeZone zone for display
purposes, so you see '2017-05-18 01:55:10-07' --- which is the same time
instant, just in a different zone.
I think perhaps what's confusing you is that PG's timestamptz values don't
store a zone value but just a time instant, which is why timestamptz_out
has to assume a zone to display in. That's not really per SQL spec, but
changing it would be very difficult, so I'm not holding my breath waiting
for it to happen.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2017-05-18 16:24 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-05-18 16:09 BUG #14660: Conversion to UTC not properly computed tbrandys@webcellence.com
2017-05-18 16:24 ` Marko Tiikkaja <marko@joh.to>
2017-05-18 16:24 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox