Page 1 of 1

Postgres Timezone change

Posted: Sat 24 Oct 2009 21:02
by rchostakovis
Hi,

How do I change the timezone of Postgres session?

Thanks

Roberto Chostakovis

Posted: Mon 26 Oct 2009 09:05
by Plash
You should execute the following SQL command:

Code: Select all

  SET TIME ZONE 

Posted: Mon 26 Oct 2009 15:36
by rchostakovis
Hi,

I tried this using TUniSql but it doesn´t work.

UniDAC appears to use the computer´s time zone and not allow to change this.

Running the scripts (select and timezone change) manually works fine.

Regards

Roberto Chostakovis

Posted: Tue 27 Oct 2009 09:15
by Plash
UniDAC always uses the computer time zone for TIMESTAMP WITH TIMEZONE fields. UniDAC does not use PostgreSQL client, and UniDAC does not contain the time conversion rules for all time zones. UniDAC uses time conversion rules from Windows settings.

Posted: Tue 27 Oct 2009 11:04
by rchostakovis
How do I change this?

I am using UniDAC in a webserver application that runs under GMT+0.

I have users from many timezones using it and I have to convert the timestamp for their location.

I have to be able at least to sum or subtract # hours from timestamp. How I do that?

Regards

Roberto Chostakovis

Posted: Tue 27 Oct 2009 11:15
by rchostakovis
Could you please tell me where the conversion take place in source code?

My subscription include source code and I can try to create a workaround.

Regards

Roberto Chostakovis

Posted: Wed 28 Oct 2009 10:09
by Plash
See the UTCTimeToLocalTime function in the PgObjects unit.

Posted: Wed 28 Oct 2009 12:13
by rchostakovis
Thank you! I got how it works and create a workaround.

I´ve changed the PgObjectsUni.pas in the following ways:

1 - Change the TimeZoneInformation variable to UniDACPgTimeZoneInfomation and moved it to Interface section, making it Global.

2 - Changed the functions that use this variable.

3 - The UniDACPgTimeZoneInformation is initialized as it was, with no change.

On my projet, I include PgObjectsUni at uses clausule and at runtime changed the bias value to reflect the timezone that I want.

I think that is a very simple way to give flexibility to UniDAC to handle with timezones.

Would you like that I send the PgObjectsUni.pas to you?

Regards

Roberto Chostakovis

Posted: Thu 29 Oct 2009 08:21
by Plash
We have made such changes ourselves:

We have renamed TimeZoneInformation to PgTimeZoneInformation and placed it to the interface section. This fix will be included in the next UniDAC build.