Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 73270B5DC07 for ; Tue, 6 Sep 2011 23:08:42 -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 27373-01 for ; Wed, 7 Sep 2011 02:08:34 +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 82729B5DBCE for ; Tue, 6 Sep 2011 23:08:17 -0300 (ADT) Received: (from bruce@localhost) by momjian.us (8.11.6/8.11.6) id p8728GK10336; Tue, 6 Sep 2011 22:08:16 -0400 (EDT) From: Bruce Momjian Message-Id: <201109070208.p8728GK10336@momjian.us> Subject: Re: Setting timezone: is it bug or intended? In-Reply-To: <22785.1303854530@sss.pgh.pa.us> To: Tom Lane Date: Tue, 6 Sep 2011 22:08:16 -0400 (EDT) CC: Yura Sokolov , 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=-2.404 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201109/53 X-Sequence-Number: 31070 Tom Lane wrote: > Bruce Momjian writes: > > Tom Lane wrote: > >> It already is documented. See > >> http://developer.postgresql.org/pgdocs/postgres/datatype-datetime.html#DATATYPE-TIMEZONES > >> specifically the point that POSIX zone names have the opposite sign > >> convention from ISO-8601. > >> > >> The great thing about standards is there are so many to choose from ;-) > > > What isn't documented is why the sign changes for +0300 but not +03: > > +03:00 is a legal POSIX zone name (hence the sign is different from SQL > convention). The other one is evidently being handled by this code path > in check_timezone: > > /* > * Try it as a numeric number of hours (possibly fractional). > */ > hours = strtod(*newval, &endptr); > if (endptr != *newval && *endptr == '\0') > { > /* Here we change from SQL to Unix sign convention */ > myextra.CTimeZone = -hours * SECS_PER_HOUR; > myextra.HasCTZSet = true; > } > > which I think is legacy code meant to deal with SQL-standard > specification of timezone offsets as INTERVAL values. You get the same > interpretation of sign when you use the SQL-spec syntax: > > regression=# set time zone interval '+03:00'; > SET > regression=# select now(); > now > ------------------------------- > 2011-04-27 00:44:53.560295+03 > (1 row) > > Like I said, too many standards with their fingers in this pie. I assume we decided we can't improve this. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. +