Timezone Finder

8.2.2 · active · verified Thu Apr 09

timezonefinder is a Python package for efficiently determining the timezone of any geographic point on Earth (given its coordinates) entirely offline. It uses a custom database of timezone polygons. The current stable version is 8.2.2. The library is actively maintained, with significant updates and breaking changes occurring with major version releases, such as v8.0.0 in early 2024.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize `TimezoneFinder` and use `timezone_at` to find the timezone for specific geographic coordinates. It highlights the use of named arguments for longitude and latitude to avoid common coordinate order mistakes.

from timezonefinder import TimezoneFinder

tf = TimezoneFinder()

# Example coordinates: Berlin, Germany
longitude = 13.4050
latitude = 52.5200

# Find the timezone at the given coordinates
timezone_str = tf.timezone_at(lng=longitude, lat=latitude)

print(f"The timezone at ({latitude}, {longitude}) is: {timezone_str}")

# Example where no timezone is found (e.g., open ocean)
longitude_ocean = 0.0
latitude_ocean = 0.0
empty_timezone_str = tf.timezone_at(lng=longitude_ocean, lat=latitude_ocean)

print(f"The timezone at ({latitude_ocean}, {longitude_ocean}) is: {empty_timezone_str}")

view raw JSON →