Re: Time Zone design issues

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: Time Zone design issues
Дата
Msg-id 20070910145645.GA16512@svana.org
обсуждение исходный текст
Ответ на Re: Time Zone design issues  (novnov <novnovice@gmail.com>)
Ответы Re: Time Zone design issues  (novnov <novnovice@gmail.com>)
Re: Time Zone design issues  (Alvaro Herrera <alvherre@commandprompt.com>)
Список pgsql-general
On Mon, Sep 10, 2007 at 07:46:17AM -0700, novnov wrote:
> But 'apps all know to adjust for TZ'; really? In this case I'm creating the
> app, I can't imagine that it will automatically know to adjust for TZ? The
> postgres function now() would output now as far as the server is concerned
> (per it's local time setting I suppose), but very surprising is there is
> enough magic to report to user time as adjusted to their time zone as
> recorded in the db?

Look up the definition of the time() function. In UNIX time is measured
in seconds since 1 Jan 1970 UTC. This is a number that is obvisouly the
same no matter where you are in the world. The C library has a function
called localtime() that does all the magic of converting to whatever
you consider local time.

The postgres function now() is the same: it returns a number of seconds.
Only when you actually go to display it does it do the localtime()
dance (internally) to make it look nice. That why you can set the
timezone to whatever you like and everything works the same.

I can log into a number of servers in the world and I just have it
setup to export TZ="my timezone" and everything is in my timezone, no
matter where the machine is or whatever anyone else on the machine is
doing. It's not magic, just someone 30 years ago making the smart
choice.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: novnov
Дата:
Сообщение: Re: Time Zone design issues
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Postgresql 7.3 on Red Hat Enterprise 5 (Problem with SEMMNI, SEMMNS)