On Tuesday 23 July 2013 11:45:09 pnorman wrote:<br>
> > The issue may be something along the lines that Postgres (or the client<br>
> > library) is assuming "without timezone" means "in local timezone"<br>
><br>
> I believe that's what without timezone is defined as in the SQL standard<br>
<br>
The server just replies in a "YYYY/MM/DD HH:MM:SS.nnn" format that has no<br>
concept of a timezone. It is the client who attaches an implicit timezone<br>
(certainly its local timezone) to that value.<br>
<br>
> > A simple work-around may be to set $TZ when running Osmosis.<br>
<br>
That's a good quickfix, but means that the whole of osmosis will run with<br>
the server's timezone, which might be overkill.<br>
<br>
A cleaner option is to use the [AT TIME ZONE](http://www.postgresql.org/docs/current/static/functions-datetime.html#FUNCTIONS-DATETIME-ZONECONVERT) construct when running an sql query:<br>
<br>
SELECT date AT TIME ZONE 'utc' from current_foobar;<br>
<br>
This will tell PG that the 'without timezone' value is stored in UTC. The<br>
server can then check the client's timezone setting, and send the value in<br>
the client's expected timezone. It works similarly for inserts. This has<br>
the advantage that a regional osm website can continue to use its local<br>
timezone for user-facing timestamps without getting confused the the server's<br>
timezone.<br>
<br>
It's not as clean a solution as altering the db schema (because it requires<br>
the client to modify its sql queries and it requires the client code to know<br>
what timezone the server's timestamps actualy are in), but it avoid the<br>
lenghty "alter table".<br>
<br>
> I also need to try inserting by hand to see what results I get<br>
<br>
tokill=# show time zone;<br>
Europe/Paris<br>
tokill=# \d foo<br>
d_notz | timestamp without time zone | <br>
d_tz | timestamp with time zone | <br>
tokill=# insert into foo values ('2013/01/01 00:00:00', '2013/01/01 00:00:00'),('2013/01/01 00:00:00', '2013/01/01 00:00:00' at time zone 'utc');<br>
INSERT 0 2<br>
tokill=# select d_notz, d_notz at time zone 'utc', d_tz from foo;<br>
2013-01-01 00:00:00 | 2013-01-01 01:00:00+01 | 2013-01-01 00:00:00+01<br>
2013-01-01 00:00:00 | 2013-01-01 01:00:00+01 | 2012-12-31 23:00:00+01
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href='https://github.com/openstreetmap/openstreetmap-website/issues/375#issuecomment-21479063'>view it on GitHub</a>.<img src='https://github.com/notifications/beacon/uTRSc6ihLa7Shf84BpiOpu5p-sEO603Adi0xI76mcGfT_gJWm4GdBKeaxLg8tieb.gif' height='1' width='1'></p>