Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 85B131337BF8 for ; Tue, 26 Apr 2011 15:48:30 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 50750-08 for ; Tue, 26 Apr 2011 18:48:22 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from momjian.us (momjian.us [70.90.9.53]) by mail.postgresql.org (Postfix) with ESMTP id EA5C41337B83 for ; Tue, 26 Apr 2011 15:48:21 -0300 (ADT) Received: (from bruce@localhost) by momjian.us (8.11.6/8.11.6) id p3QImJX06900; Tue, 26 Apr 2011 14:48:19 -0400 (EDT) From: Bruce Momjian Message-Id: <201104261848.p3QImJX06900@momjian.us> Subject: Re: Setting timezone: is it bug or intended? In-Reply-To: <4D892810.5040001@gmail.com> To: Yura Sokolov Date: Tue, 26 Apr 2011 14:48:19 -0400 (EDT) CC: Susanne Ebrecht , pgsql-bugs@postgresql.org X-Mailer: ELM [version 2.4ME+ PL124 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="US-ASCII" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201104/199 X-Sequence-Number: 30118 Yura Sokolov wrote: > 21.03.2011 15:51, Susanne Ebrecht ?????: > > Hello Yora Sokolov, > > > > Maybe this is not a bug - just an inconsistence: > > > > Look here (tested with 9.0): > > > > =# set timezone='+3.5'; > > SET > > =# select current_timestamp; > > now > > ---------------------------------- > > 2011-03-21 16:05:34.761112+03:30 > > (1 row) > > > > In any case, this should get documented. > > > > Susanne > > > > > My question were about sign of timezone: > > postgres=# set timezone='+03'; -- positive > postgres=# select now(); > 2011-03-18 11:20:29.696671+03 -- positive > postgres=# set timezone='+03:00'; -- positive > 2011-03-18 05:20:35.46008-03 -- negative > > Is it intended? Uh, it certainly looks very odd. What I believe is happening is that +03:00 is processed as a real time zone specification: test=> set timezone='+03:00'; SET test=> show timezone; TimeZone ---------- --> +03:00 (1 row) test=> select now(); now ------------------------------- 2011-04-26 15:41:11.409237-03 (1 row) You will notice that because of the SQL standard, GMT+3 processes as -03 utc_offset, and '+03:00' must be processed the same: test=> select * from pg_timezone_names; name | abbrev | utc_offset | is_dst ----------------------------------+--------+------------+-------- ... Etc/GMT+3 | GMT+3 | -03:00:00 | f The '+03' is seen as hours-minutes-seconds: test=> set timezone='+03'; SET test=> show timezone; TimeZone ---------- --> 03:00:00 (1 row) test=> select now(); now ------------------------------- 2011-04-26 21:40:57.570654+03 (1 row) hence the +03. Notice how different that looks from the +03:00 above. As far as how to even document this, I have no idea. I think this code is being processed by the timezone library we include as part of Postgres. I am lost on how to proceed. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. +