@vybornyj/input-to-utc
v1.3.1
Published
Get UTC Date from input: city, year, month, day, hour, minute
Downloads
6
Readme
I recommend using module on the server side to keep API keys private.
Required API Keys
Google Cloud (for Place Autocomplete API
and Maps Geocode API
)
Get $200 in free usage for Maps, Routes, and Places every month
TimeZoneDB (for Get Time Zone API
)
TimeZoneDB API is free for personal and non-commercial usage. There are no limits on how many queries you can make, but there is a rate limit where you can only send request to the server once per second. Additional queries will get blocked.
Install
npm i @vybornyj/input-to-utc
or
yarn add @vybornyj/input-to-utc
Usage
Step 1: Autocomplete City and Get cityId
import { autocompleteCity } from '@vybornyj/input-to-utc'
const GOOGLE_API_KEY = '000000000000000000000000000000000000000'
const city = 'Lond'
const cities: {city: string, cityId: string}[] = await autocompleteCity(GOOGLE_API_KEY, city)
Step 2: Get dateUTC
by input date-time and cityId
import { calcDateUtc } from '@vybornyj/input-to-utc'
const GOOGLE_API_KEY = '000000000000000000000000000000000000000'
const TIMEZONEDB_API_KEY = '000000000000'
const cityId = cities[0].cityId
const year = '2027'
const month = '12'
const day = '31'
const hours = '23'
const minutes = '59'
const dateUTC: Date | null = await calcDateUtc(GOOGLE_API_KEY, TIMEZONEDB_API_KEY, cityId, { year, month, day, hours, minutes })