Timezone fun (bugs and a request) - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Timezone fun (bugs and a request)
Date
Msg-id 20040523195158.GB15995@dcc.uchile.cl
Whole thread Raw
Responses Re: Timezone fun (bugs and a request)  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Timezone fun (bugs and a request)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
I'm looking at the new timezone support.

First I initdb'd without TZ set.  So every time I start the server I get

LOG:  could not recognize system timezone, defaulting to "Etc/GMT-4"
HINT:  You can specify the correct timezone in postgresql.conf.

Obviously the setup is wrong because DST doesn't work:

alvherre=# select '2004-03-13 10:00:00'::timetz;  timetz    
-------------10:00:00+04
(1 fila)

alvherre=# select '2004-03-14 10:00:00'::timetz;  timetz    
-------------10:00:00+04
(1 fila)

alvherre=# set TimeZone to 'Chile/Continental';
SET
alvherre=# select '2004-03-13 10:00:00'::timetz;  timetz    
-------------10:00:00-03
(1 fila)

alvherre=# select '2004-03-14 10:00:00'::timetz;  timetz    
-------------10:00:00-04
(1 fila)

Note I get +4 on the default zone and -4 on the correct zone.  I think
this is a bug.


So I went and set it in postgresql.conf,
timezone = 'Chile/Continental'

After this, DST works correctly, but I continue to receive the LOG
message above.  I think it should be supressed.

I then changed postgresql.conf to read

timezone = unknown
(the difference with the original setting is that the line isn't
commented).  

The server now behaves different; the timezone is set to GMT rather than
being guessed from system settings.  I think they should work the same.



I also want to be able to specify a non-default timezone and get a time
with the correct displacement.  CLT is abbreviation for
Chile/Continental, and CLST is the summer timezone.

alvherre=# select '10:00:00'::time at time zone 'CLT'; timezone   
-------------10:00:00-04
(1 fila)

alvherre=# select '10:00:00'::time at time zone 'CLST'; timezone   
-------------11:00:00-03
(1 fila)

alvherre=# select '10:00:00'::time at time zone 'Chile/Continental';
ERROR:  el huso horario "chile/continental" no es reconocido


I would like to get the time in the corresponding zone, without me
having to know in advance whether I'm in current DST or not.  Is this
possible?  For example I want to know what's the current time in
'Europe/Madrid'.

-- 
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Puedes vivir solo una vez, pero si lo haces bien, una vez es suficiente"



pgsql-hackers by date:

Previous
From: "Ziga Kranjec"
Date:
Subject: Re: eval function
Next
From: Tom Lane
Date:
Subject: Re: Fixing the Turkish problem