I am currently creating application which requires Current Time From the Country.
I have latitude and longitude of different Country.
I have use following Link to get the Current Time
http://api.geonames.org/timezone?lat=21.7679&lng=78.8718&username=demo
(demo user name is by default and used only for testing because it has query limit)
I got the current Time but when Daylight Saving Time is ON. Is that API gives me the correct Time? If not then how could i get the current Time.
In some of the API I get the current time like earthtool(not implemented DST). But i could not Test because currently there is no DST Implemented so how can i test in this case?
I am Creating Application in .NET with C# 4.0
If any other API then please Tell Me but first priority to GeoNames API.
I would be very surprised if that didn't reflect the current local time. The results for Sao Paolo (which is currently observing DST) seem to agree with that:
<geonames>
<timezone tzversion="tzdata2012f">
<countryCode>BR</countryCode>
<countryName>Brazil</countryName>
<lat>-23.0</lat>
<lng>-46.0</lng>
<timezoneId>America/Sao_Paulo</timezoneId>
<dstOffset>-3.0</dstOffset>
<gmtOffset>-2.0</gmtOffset>
<rawOffset>-3.0</rawOffset>
<time>2012-12-17 10:48</time>
<sunrise>2012-12-17 06:14</sunrise>
<sunset>2012-12-17 19:47</sunset>
</timezone>
</geonames>
However, another alternative would be to use the GeoNames API to get the time zone ID, and then use Noda Time for everything to do with that time zone. (Disclaimer: I'm the primary developer of Noda Time.)
You can't just use the BCL's TimeZoneInfo
class directly, as that doesn't support TZDB the time zone IDs that GeoNames provides (e.g. "Asia/Kolkata"). You could just use a mapping (CLDR provides one) but in my experience the Windows time zone information has some disturbing oddities.
If you just need to know the current time, GeoNames is probably fine -