Thread: Timestamp with time zone 'negative' problem

Timestamp with time zone 'negative' problem

From
"Prodan, Andrei"
Date:
Hello,

I have a DB in which items which are 'always valid' have a from_date of
19000101 000000+1 (Europe/Berlin)
When i try to restore the same DB to (Europe/Bucharest), instead of
19000101 000000+2, the timestamp becomes "1900-01-01 00:44:24+01:44:24"
which is ... strange.
My software then complains (...correctly) that 01:44:24 is not a valid
timezone.

Am i doing something wrong, or should i report this to pg-bugs?
Is there any way i can avoid this issue other than setting Timezone for
the DB to (Europe/Berlin)? I am considering UPDATE on the rows to 1901
or some such... but that's a very gimmicky solution.


Thank you,
Andrei Prodan
--------------------------------------------------
Awinta Consulting S.R.L.
Canaluluistr. 44
505600 Sacele
Brasov, Romania
Tel. +40368 / 441024
Fax. +40368 / 441024
--------------------------------------------------



Re: Timestamp with time zone 'negative' problem

From
Tom Lane
Date:
"Prodan, Andrei" <Andrei.Prodan@awinta.com> writes:
> I have a DB in which items which are 'always valid' have a from_date of
> 19000101 000000+1 (Europe/Berlin)
> When i try to restore the same DB to (Europe/Bucharest), instead of
> 19000101 000000+2, the timestamp becomes "1900-01-01 00:44:24+01:44:24"
> which is ... strange.

No, not particularly.  According to the Olson timezone database,
Bucharest didn't adopt standard time (that is, an integral-hours offset
from GMT) until 1931.  Before that, local midnight was true local
midnight, and they are 1:44:24 east of Greenwich, so that is what
"midnight of 1900/01/01" means in that zone.

The only reason your code fails to fail in Europe/Berlin zone is that
Berlin adopted standard time in 1893, so that midnight of 1900/01/01
is already an exact offset from GMT in that zone.

Personally, I'd suggest getting away from the magic number.  Consider
using NULL or -infinity instead of an arbitrary date.  Failing that,
don't use a place-based zone with all the historical baggage that
those entail, but something fixed like 'GMT+1'.

            regards, tom lane