GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Country code + region code --> Timezone  XML
Forum Index -> General
Author Message
j_e



Joined: 29/11/2020 23:34:10
Messages: 1
Offline

Hello,

How is it possible to get the timezone for a "country code + region code" pair?
(also known as ISO3166-1 alpha2 and ISO3166-2)

Example:

ISO3166 -> Timezone

DE-BE -> Europe/Berlin
AU-TAS -> Australia/Hobart or Australia/Tasmania
US-NY -> America/NewYork

Thank you in advance,
Jo
bhujagendra


[Avatar]
Joined: 28/11/2020 11:56:56
Messages: 4
Offline

Hi

The timezone information is included in the location information. Unfortunately it is not currently possible to use the web-based search for such a detailed query. However, you can get the information through the web services, but it requires a bit of coding still, as the ISO3166-2 code is provided by the data, but unfortunately cannot be used as a search criteria.

Read the following documentation:
https://www.geonames.org/export/web-services.html
https://www.geonames.org/export/geonames-search.html
https://www.geonames.org/export/codes.html

Which would lead to the conclusion, that you could query the information you need with the following search:
- It must be a first order administration entry (ADM1)
- In country {ISO3166-1 alpha2}

The query template would look like this:
http://api.geonames.org/search?maxRows=20&featureCode=ADM1&country={ISO3166-1 alpha2}&style=full&username=demo

Hence, the query would look like this for your first example:
http://api.geonames.org/search?maxRows=20&featureCode=ADM1&country=DE&style=full&username=demo

Then you will have to go through the results and search for Code:
<adminCode1 ISO3166-2="{ISO3166-2}">
(xml) or Code:
"adminCodes1":{"ISO3166_2":"{ISO3166-2}"}
(json).

In XML, you could do that with just an XQuery Code:
//geoname[adminCode1[@ISO3166-2="{ISO3166-2}"]]//timezone
(eg. Code:
//geoname[adminCode1[@ISO3166-2="BE"]]//timezone
)

Hope that helps!
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team