pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Yura Sokolov <funny.falcon@gmail.com>
Cc: Susanne Ebrecht <susanne@2ndQuadrant.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Setting timezone: is it bug or intended?
Date: Tue, 6 Sep 2011 22:08:16 -0400 (EDT)
Message-ID: <201109070208.p8728GK10336@momjian.us> (raw)
In-Reply-To: <22785.1303854530@sss.pgh.pa.us>

Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> 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  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +



view thread (8+ messages)

Message-ID: <201109070208.p8728GK10336@momjian.us>
Permalink:  ../201109070208.p8728GK10336@momjian.us/
Also on:    postgresql.org/message-id/201109070208.p8728GK10336@momjian.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: bruce@momjian.us, tgl@sss.pgh.pa.us, funny.falcon@gmail.com, susanne@2ndQuadrant.com
  Subject: Re: Setting timezone: is it bug or intended?
  In-Reply-To: <201109070208.p8728GK10336@momjian.us>
  References: <22785.1303854530@sss.pgh.pa.us> <201109070208.p8728GK10336@momjian.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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