0.2.0 • Published 2 years ago
worldtimeapi-lib v0.2.0
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
npminstalled. Library enforces using Node.js version 20.x or higher, due to internal usage offetchfunction.
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" });