World Time API - Ruby Gem

World Time is a simple tool for getting the current time in any city. It returns the current time, date, and more.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_worldtime'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_worldtime

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_worldtime'

# Initialize the client
client = APIVerve::Worldtime::Client.new(api_key: "YOUR_API_KEY")

# Make a request
response = client.execute({ city: "San Francisco" })

# Print the response
puts response

Error Handling

begin
  response = client.execute({ city: "San Francisco" })
  puts response["data"]
rescue APIVerve::Worldtime::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Worldtime::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

# Enable debug logging
client = APIVerve::Worldtime::Client.new(
  api_key: "YOUR_API_KEY",
  debug: true
)

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "search": "San Francisco",
    "foundCities": [
      {
        "city": "San Francisco",
        "city_ascii": "San Francisco",
        "country": "Argentina",
        "iso2": "AR",
        "iso3": "ARG",
        "province": "Córdoba",
        "timezone": "America/Argentina/Cordoba",
        "time": "19:33",
        "time24": "19:33:04",
        "time12": "07:33:04 PM",
        "date": "2025-12-16",
        "day": "Tuesday",
        "month": "December",
        "year": "2025",
        "unix": "1765924384",
        "dst": false,
        "dst_start": "2025-12-16 19:33:04",
        "dst_end": "2025-12-16 19:33:04",
        "dst_name": "-03"
      },
      {
        "city": "San Francisco",
        "city_ascii": "San Francisco",
        "country": "United States of America",
        "iso2": "US",
        "iso3": "USA",
        "province": "California",
        "state_ansi": "CA",
        "timezone": "America/Los_Angeles",
        "time": "14:33",
        "time24": "14:33:04",
        "time12": "02:33:04 PM",
        "date": "2025-12-16",
        "day": "Tuesday",
        "month": "December",
        "year": "2025",
        "unix": "1765924384",
        "dst": false,
        "dst_start": "2025-12-16 14:33:04",
        "dst_end": "2025-12-16 14:33:04",
        "dst_name": "PST"
      }
    ]
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.