I am working on an application where the user will input a date, time, and location, and I will need to convert that time into the equivalent GMT. This means I will need to locate the input data within one of the Olsen time zones in order to create and manipulate a Date::Time object.

Unfortunately, "city/province/nation" or "latitude/longitude" don't seem to convert easily into the time zone names used in Date::Time.

Example: User inputs May 15, 1973, Austin, TX, USA. I need to figure out which of the Olsen zones "Austin TX" is located in. I will have available the city/state-province/nation name, as well as ISO-3166-2 codes for US/Canada states/provinces, FIPS 10-4 codes for other nations/regions, and longitude/latitude of the specific place in question. What I need to find from this is the proper time zone to use for that date/location.

Does anyone know of any tool or routine that might be able to do this type of conversion?

G'day Ed,


Unfortunately there is no (easy) way to do this. We've looked at it before, but it just isn't possible.

Using a vector-map of the world, it is possible to calculate a person's country based upon their long/lat, but that will only be correct until the political boundaries change. Also, such a map, zipped, is about 16MB.

Next, countries are of little use for the above reason: they're political boundaries and are prone to change. Because of this, the Olsen database uses geographic areas (continents) and city names -- which are far less likely to change.

Same for states.

Now the Olsen database gets even more confusing, but more reasonable in that it doesn't even use the local capital city. It uses the largest city in the time zone, thus we have America/Los Angeles rather than America/Sacramento, and Australia/Sydney rather than Australia/Canberra (Sydney is a capital, but it's just a state capital whereas Canberra is the federal capital).

Once again this is because politics change.

Now, as for "I need to figure out which of the Olsen zones "Austin TX" is located in.", I can offer a solution: Ask the user.

We can do a few neat tricks with online resources here (and maybe we should look at including the first part with DateTime).

1. Determine and catalog a list of long/lat coords for every time zone's major city. (already done in the Olsen database, just needs perlifying.
2. Determine (by some means) the user's long/lat coords.
3. Use Math::Trig to determine the great-circle-distance to each zone's coords


We can then present the user with the closest 3, 4, 5, ... (you pick) zones and ask which they're in.

Hope this helps at least in some small way.

Cheers!
Rick











--
--------------------------------------------------------
            There are 10 kinds of people:
  those that understand binary, and those that don't.
--------------------------------------------------------
  The day Microsoft makes something that doesn't suck
    is the day they start selling vacuum cleaners
--------------------------------------------------------
"Write a wise proverb and your name will live forever."
   -- Anonymous
--------------------------------------------------------

Reply via email to