Retrieve Time Zones for a Country in Ruby
If you’re looking to simplify communications and scheduling with international clientele, this simple tool may be able to help you out. By integrating the following API into your system or website, you will be able to automatically reference the tz database and retrieve the IANA time zones for a specific country, which will make business interactions easier and more convenient for both you and your partners.
To begin the process, we will need to add the Ruby client our Gemfile:
gem 'cloudmersive-validate-api-client', '~> 2.1.6'
Once the installation is complete, we can call the function like so:
# load the gem
require 'cloudmersive-validate-api-client'
# setup authorization
CloudmersiveValidateApiClient.configure do |config|
# Configure API key authorization: Apikey
config.api_key['Apikey'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
#config.api_key_prefix['Apikey'] = 'Bearer'
endapi_instance = CloudmersiveValidateApiClient::AddressApi.newinput = CloudmersiveValidateApiClient::GetTimezonesRequest.new # GetTimezonesRequest | Input requestbegin
#Gets IANA/Olsen time zones for a country
result = api_instance.address_get_timezone(input)
p result
rescue CloudmersiveValidateApiClient::ApiError => e
puts "Exception when calling AddressApi->address_get_timezone: #{e}"
end
And that’s it! To retrieve your API key at no cost and with no commitment, visit the Cloudmersive website; this will give you access to 800 calls/month across any of our APIs.