Get timezone from country code / city

Hi all,

I am doing a Stripe integration and I would like to send a scheduled email to the customer. It should be scheduled to a given time of the day, but in his timezone.

I have a country code (ISO 3166-1 alpha-2) and a city of the customer. Those can be the inputs of a function. His approximate timezone should be the output.

Any ideas where to look? Thanks a lot.

1 Like

Maybe this? Timex.TimezoneInfo — timex v3.7.6

2 Likes

I know about these:

Any specific country/continent you are looking for ?

2 Likes

Maybe you can generate a mapping from the GeoNames data http://download.geonames.org/export/dump/readme.txt

3 Likes

Thanks a lot. I will take a look at those. Well, I am looking for all continents. :slight_smile:
I am aware, that there are countries with multiple timezones, in that case some average of those would be enough.

Maybe even something simple like this would be enough:

# SVK is Europe/Bratislava (in Slovakia)
# +1 is UTC offset in our country.
my_function("SVK") # +1
2 Likes

Check TzExtra and its TzExtra.countries_time_zones/1 function (it depends on Tz).

And GitHub - kimlai/tz_world: Resolve timezones from a location. ?

4 Likes

Nice, no need to deal directly with external databases and mappings.

2 Likes

Thanks a lot. That is exactly what I need. :hugs: