GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Calculating Timezone using information obtained from the API  XML
Forum Index -> General
Author Message
krnekhelesh



Joined: 11/06/2013 18:52:47
Messages: 3
Offline

Hi everyone,

@Dev who is providing this service, thank you very much! It is a life saver.

I am currently confused slightly about the timezone. Let me first describe my situation.

I am the developer of the clock app for the Ubuntu Touch platform for mobiles, tablets and desktops. One of the planned features is World Clocks. I have already implemented quite a bit of it, but am unable to proceed further without making a decision. My original plan was to allow the user to search for a city, which would then in turn retrieve the city's timezone info. However I only intend to to do this once and then perhaps update every week or so to see if the timezone has changed (due to DST or whatever). With this plan, I ruled out retrieving the local time using the api since it is only useful at that point. Instead I retrieved the rawOffset since I can use that to calculate the time at a particular location by adding the offset to UTC. I also did read that GmtOffSet and DstOffset is deprecated (in the docs).

However, I noticed that that rawOffset works for countries which do not have DST. While in cities like London, my time calculation was off by an hour.

Do you have any ideas on how to solve this problem?

Should I instead retrieve the local time at the destination and compare it with my system (app) time and then get the diff. I can then probably use the diff to calculate the time at the destination in the near future?

I just feel that by checking the local time using the API every day is a bit too much for a mobile app.
saphir



Joined: 05/06/2010 22:44:39
Messages: 130
Offline

Hi krnekhelesh

I read the output this way >>
rawOffset = gmtOffset = StandardTime TimeZone
dstOffset = DST TimeZone
...these are invariable values, just to show the possible range, they say nothing about the true time there...

This works for me >>
My system gives me my true System-Time as GMT/UTC
GeoNames returns the true local time in the local TimeZone, DST corrected

diffToGMT = TrueLocalTime - TrueSystemGMTtime
TrueLocalTimeZone = Round(4 * diffToGMT, 0) / 4

...the "4" are to return the TimeZone in 15 min steps (...yes, even a 5.75 and a 12.75 TimeZone exist)

Now you have the TrueLocalTimeZone... until the next recalculation...

Regards
Urs
marc



Joined: 08/12/2005 07:39:47
Messages: 4501
Offline

Hi krnekhelesh

The timezone identifier should normally be sufficient. Most programming environments have the DST rules included and all you need is this identifier. The rules for DST are very different from timezone to timezone and may also change from year to year.

Java for instance has this class:
http://docs.oracle.com/javase/6/docs/api/java/util/TimeZone.html

Marc

[WWW]
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team