473,773 Members | 2,286 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about timezones

Hi,

The operating system I run (Linux) comes with many, many timezone files
for many different places in the world. For example:

$ TZ='Australia/Sydney' date
Fri Oct 8 06:15:31 EST 2004
$ TZ='Europe/Amsterdam' date
Thu Oct 7 22:15:38 CEST 2004
$ TZ='Africa/Bissau' date
Thu Oct 7 20:18:44 GMT 2004
$ TZ='America/Phoenix' date
Thu Oct 7 13:19:33 MST 2004

Is there any way I can use these from within postgresql? Those files
contains details about daylight saving changes and other useful details
like that, which a simple PST or EST won't cover. Or should I simply do
all my date/time conversion in my application?

Any ideas?
--
Martijn van Oosterhout <kl*****@svana. org> http://svana.org/kleptog/
Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
tool for doing 5% of the work and then sitting around waiting for someone
else to do the other 95% so you can sue them.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQFBZaV9Y5T wig3Ge+YRApJeAK CdssMcZvYf/tI+kz4dGHfhSUPQ 4QCgybof
8IKubXWTwLzezo3 xCP10FrQ=
=gy0g
-----END PGP SIGNATURE-----

Nov 23 '05 #1
4 2014
* Martijn van Oosterhout <kl*****@svana. org> [2004-10-07 22:22:24 +0200]:
Is there any way I can use these from within postgresql? Those files
contains details about daylight saving changes and other useful
details like that, which a simple PST or EST won't cover. Or should
I simply do all my date/time conversion in my application?


The time zone support seems pretty exhaustive. Check out section B-r
in the document below.

http://www.postgresql.org/docs/7.4/s...-keywords.html

HTH,

--
Steven Klassen - Lead Programmer
Command Prompt, Inc. - http://www.commandprompt.com/
PostgreSQL Replication & Support Services, (503) 667-4564

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #2
On Thu, Oct 07, 2004 at 01:43:49PM -0700, Steven Klassen wrote:
* Martijn van Oosterhout <kl*****@svana. org> [2004-10-07 22:22:24 +0200]:
Is there any way I can use these from within postgresql? Those files
contains details about daylight saving changes and other useful
details like that, which a simple PST or EST won't cover. Or should
I simply do all my date/time conversion in my application?
The time zone support seems pretty exhaustive. Check out section B-r
in the document below.

http://www.postgresql.org/docs/7.4/s...-keywords.html


But it doesn't seem to work to actually work out times across the
world w.r.t. daylight savings.

For example, this script works out, given a time in one timezone, what
it was in another timezone:

$ sh /tmp/translatetz '2004-12-01 12:0:0' Australia/Sydney Europe/Amsterdam
Wed Dec 1 02:00:00 2004
$ sh /tmp/translatetz '2004-08-01 12:0:0' Australia/Sydney Europe/Amsterdam
Sun Aug 1 04:00:00 2004

But Brisbane doesn't have summer time, so:

$ sh /tmp/translatetz '2004-12-01 12:0:0' Australia/Brisbane Europe/Amsterdam
Wed Dec 1 03:00:00 2004

The closest I've been able to get is:

kleptog=# select timezone('MEWT' ,timezone('AESS T','2004-12-01 12:0:0'::timest amp));
timezone
---------------------
2004-12-01 02:00:00
(1 row)

kleptog=# select timezone('MEST' ,timezone('AEST ','2004-08-01 12:0:0'::timest amp));
timezone
---------------------
2004-08-01 04:00:00
(1 row)

In other words, if I work out myself the appropriate timezones then it
can do it. In that case I may just as well do it all myself. Mind you,
this is 7.3, would a more recent version handle this differently?

--- translatetz ---
#!/bin/sh
X=`TZ=$2 date --date="$1" +%s`
TZ=$3 perl -e 'print scalar(localtim e(shift))' $X
--- snip ---
--
Martijn van Oosterhout <kl*****@svana. org> http://svana.org/kleptog/ Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
tool for doing 5% of the work and then sitting around waiting for someone
else to do the other 95% so you can sue them.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQFBZk5ZY5T wig3Ge+YRAmntAJ 9TNc3XqI59fjoL+ V+Z68/Ge1wSDgCcC86c
qF1Kzmm/OTpsPmVDEaENEL8 =
=BPj9
-----END PGP SIGNATURE-----

Nov 23 '05 #3
Martijn van Oosterhout <kl*****@svana. org> writes:
But it doesn't seem to work to actually work out times across the
world w.r.t. daylight savings.
...
For example, this script works out, given a time in one timezone, what
it was in another timezone:


What we need for that is the ability for AT TIME ZONE to specify a
DST-aware zone name. Right now it can only take DST-ignorant zone
names. So you can do
('2004-12-01 12:0:0' AT TIME ZONE 'AESST') AT TIME ZONE 'MEWT'
but not
('2004-12-01 12:0:0' AT TIME ZONE 'Australia/Sydney') AT TIME ZONE 'Europe/Amsterdam'
which of course is what you want.

The infrastructure needed for this is finally present in 8.0, ie we have
the timezone data available, but actually teaching AT TIME ZONE about it
didn't get done in time. Likely it will appear in 8.1 (especially if
you step up and do the work ;-)).

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #4
On Fri, Oct 08, 2004 at 09:52:00AM -0400, Tom Lane wrote:
The infrastructure needed for this is finally present in 8.0, ie we have
the timezone data available, but actually teaching AT TIME ZONE about it
didn't get done in time. Likely it will appear in 8.1 (especially if
you step up and do the work ;-)).
I've had a look at the code that is in CVS and it looks like everything
needed is basically there. I think what's basically needed is a system
to keep track of tzname => struct state mappings, probably a hash of
some sort.

I'd consider creating a timezone preserving type, but it's not
necessary for what I'm doing. Is that library already built into 8.0?
If that's the case there is an opportunity to create a contrib module
that hooks into it.

Hmm...
--
Martijn van Oosterhout <kl*****@svana. org> http://svana.org/kleptog/ Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
tool for doing 5% of the work and then sitting around waiting for someone
else to do the other 95% so you can sue them.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQFBco+fY5T wig3Ge+YRAns2AK DVAEedXNcEkyvRa XBZIQC67mIHxgCg lj6J
qg6szfZ90gH4w1A kB4A3Oik=
=zhTx
-----END PGP SIGNATURE-----

Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1342
by: B. G. Mahesh | last post by:
hi I am using PHP 4.x and MySQL. The database has the list of countries, cities and timezones. I would like to convert the time from one zone to another zone . It is not that difficult to convert but I was wondering if the language itself supports the conversion which I would prefer using. Any other tips is appreciated
13
7027
by: Michael | last post by:
I would like to set the timezone of a thread to allow me to calculate the UTC time for data sourced from a number of time zones. Although this can be done in C and C++, I annot find how to do this is C#. Can this be done ? If so how ? Please note setting the culture does not impact the timezone and a culture (like en-US) may have many timezones.
0
1150
by: Robert Treat | last post by:
I am trying to figure out if there is a way to determine the timezones supported in postgresql from within the database. If you look at http://www.postgresql.org/docs/7.4/static/datetime-keywords.html it notes that time zone information is system dependent, (I interpret to mean that anything I find in /usr/share/zoneinfo on linux should be supported, can someone confirm that?) so how can an external app determine which timezones are...
1
2135
by: Flack | last post by:
Hey guys, I need to compare two times that the user selects. The user selects the hour, date, and timezone (which can be either NY, LN, or HK timezones). How can I compare two dates of different timezones? For example: Date1 = 11:30, 4/18/06, NY Date2 = 16:30, 4/18/06, LN These times should be considered equal (since of course LN time is +5 NY
5
7805
by: Alex | last post by:
Hi My website is hosted in the States (EST), but the website itself is targeted for UK users (GMT). How can I offset the time so that the server reports it as GMT when my ASP.NET app needs to find out the current time? .. Can I do this in web.config? If so how exactly?
7
4266
by: =?Utf-8?B?U3R1?= | last post by:
I have a ASP.NET Ajax app (using client library) calling ASP.NET Ajax-enabled web services. We are making use of the javascript proxies generated by ASP.NET Ajax. The problem we have is that the UTC dates sent by the browser are being adjusted for timezones by the server, but we do not want dates adjusted for timezones. For example, the user enters the date of a transaction as '25 May 2007'. That ends up as a javascript Date()...
3
3087
by: Daz | last post by:
Hello everyone. I am creating a JavaScript project which will allow users to see what time it is in other countries. I am wondering if there's any way to have the server work this out, without having to update a database constantly with the times and dates that certain countries set their clocks back or forward. Can this be done, or do I need to connect to a time server? Ideally, I need a time server that will return a JavaScript...
7
3859
by: David T. Ashley | last post by:
In a web database (PHP), per user, I'd like to allow each user to specify their timezone (this would change how times are adjusted for display for that user). How do I enumerate all possible timezones from a PHP script or compiled 'C' program? Given a specific timezone, how do I get the time adjustment from UTC (which can vary, based on daylight savings rules)?
27
5323
by: Sanjay | last post by:
Hi All, I am using pytz.common_timezones to populate the timezone combo box of some user registration form. But as it has so many timezones (around 400), it is a bit confusing to the users. Is there a smaller and more practical set? If not, some suggestions on how to handle the registration form effectively would help me a lot. thanks Sanjay
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6717
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.