0.2.0 • Published 1 year ago

worldtimeapi-lib v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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" });
0.2.0

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago