Skip to content

Latest commit

 

History

History
55 lines (36 loc) · 1.11 KB

README.md

File metadata and controls

55 lines (36 loc) · 1.11 KB

world time API lib

This simple library exposes one function getTimezone, which will take care of everything the underlying API allows.

Preconditions

  • have Node.js LTS with npm installed. Library enforces using Node.js version 20.x or higher, due to internal usage of fetch function.

Usage

Get all timezones' areas

import { getTimezone } from "worldtimeapi-lib";

const [data, status] = await getTimezone();

if (status) {
  console.log(JSON.stringify(data));
}

Get specific area with its locations

const [data, status] = await getTimezone({ timezone: "Europe" });

Get specific location data of the area timezone

const [data, status] = await getTimezone({ timezone: "Europe/Prague" });

Get data for IP address

IP address is not provided

import { getIpAddress } from "worldtimeapi-lib";

const [data, status] = await getIpAddress();

if (status) {
  console.log(JSON.stringify(data));
}

IP address explicitly provided

const [data, status] = await getIpAddress({ ip: "8.8.8.8" });