Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 267441337B92 for ; Tue, 26 Apr 2011 18:49:23 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 42799-03-2 for ; Tue, 26 Apr 2011 21:49:05 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 335DC1337BFD for ; Tue, 26 Apr 2011 18:48:54 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p3QLmog6022786; Tue, 26 Apr 2011 17:48:50 -0400 (EDT) To: Bruce Momjian cc: Yura Sokolov , Susanne Ebrecht , pgsql-bugs@postgresql.org Subject: Re: Setting timezone: is it bug or intended? In-reply-to: <201104262130.p3QLUQI10021@momjian.us> References: <201104262130.p3QLUQI10021@momjian.us> Comments: In-reply-to Bruce Momjian message dated "Tue, 26 Apr 2011 17:30:26 -0400" Date: Tue, 26 Apr 2011 17:48:50 -0400 Message-ID: <22785.1303854530@sss.pgh.pa.us> From: Tom Lane 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/203 X-Sequence-Number: 30122 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. regards, tom lane