pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laszlo Nagy <gandalf@shopzeus.com>
To: pgsql-admin@postgresql.org
Cc: Daniel Fekete <dani@shopzeus.com>
Subject: Messed up time zones
Date: Fri, 03 Aug 2012 10:31:43 +0200
Message-ID: <501B8C6F.6040100@shopzeus.com> (raw)

select abbrev,utc_offset,count(*) from pg_timezone_names
where abbrev='EST'
group by abbrev,utc_offset

There are 12 times zones with 'EST' code, offset = GMT+10. And there are 
8 time zones with 'EST' code, offset= GMT+5 at the same time!

So how much it is supposed to be?

select now() at time zone 'UTC' - now() at time zone 'EST'

(Actually it returns +5:00 but what is the explanation?)

And how am I supposed to convert a date to Australian zone? This doesn't 
work:

select now() at time zone 'Australia/ATC' -- time zone "Australia/ATC" 
not recognized

Background: we have a site where multiple users are storing data in the 
same database. All dates are stored in UTC, but they are allowed to give 
their preferred time zone as a "user preference". So far so good. The 
users saves the code of the time zone, and we convert all timestamps in 
all queries with their preferred time zone. But we got some complaints, 
and this is how I discovered the problem.

Actually, there are multiple duplications:


select abbrev,count(distinct utc_offset)
from pg_timezone_names
group by abbrev
having count(distinct utc_offset)>1
order by 2 desc


"CST";3
"CDT";2
"AST";2
"GST";2
"IST";2
"WST";2
"EST";2


How should I store the user's preferred time zone, and how am I supposed 
to convert dates into that time zone?

Thanks,

    Laszlo




view thread (17+ messages)  latest in thread

Message-ID: <501B8C6F.6040100@shopzeus.com>
Permalink:  ../501B8C6F.6040100@shopzeus.com/
Also on:    postgresql.org/message-id/501B8C6F.6040100@shopzeus.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: gandalf@shopzeus.com, pgsql-admin@postgresql.org, dani@shopzeus.com
  Subject: Re: Messed up time zones
  In-Reply-To: <501B8C6F.6040100@shopzeus.com>

* 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