Skip to main content

A wrapper for the World Time API.

Project description

World Time Wrapper

This package provides an easy interface with the World Time API site.

To install:

python3 -m pip install world-time-api

This requires the requests module if you don't already have it installed.

Usage

To start, create a client for one of the endpoints (currently they only offer 'ip' and 'timezone' endpoints). The below example returns the time in New York.

from WorldTimeAPI import services as serv

myclient = serv.client('timezone')
requests = {"area":"America","location":"New_York"}

# Returns a DateTimeJSON object
response = myclient.get(**requests)

print(response.datetime)

To get a list of regions and locations:

# Returns ListJSON : NOTE: this is only valid for the 'timezone' endpoint
regions = myclient.regions()
print(regions.data)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

world-time-api-2020.5.31.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distribution

world_time_api-2020.5.31-py3-none-any.whl (4.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page