@neetohq/timezones
v0.2.2
Published
![npm version](https://img.shields.io/npm/v/@neetohq/timezones.svg) ![license](https://img.shields.io/npm/l/@neetohq/timezones.svg)
Downloads
1,018
Readme
@neetohq/timezones
A simple and lightweight NPM package for working with time zones. This package provides a human friendly timezone selector and utility functions for timezones.
Installation
You can install the package using npm:
npm install @neetohq/timezones
NeetoTimezoneSelector
import { NeetoTimezoneSelector } from "@neetohq/timezones";
new NeetoTimezoneSelector(document.getElementById("elementId"));
Configuration
You can pass options as the second parameter to configure the timezone selector component.
- elementId: ID for the NeetoTimezoneSelector. By default the ID will be
timezone-selector
- className: Custom classes that can be added to the component.
- onChange: Function to be called when the timezone selector changes.
- position: Position in which the selector should open in. Available options:
top
,bottom
. Default position isbottom
. - onHourFormatChange: Function to be called when the time format changes.
import { NeetoTimezoneSelector } from "@neetohq/timezones";
new NeetoTimezoneSelector(document.getElementById("elementId"), {
className: "custom-selector-class",
onChange: (timezone) => {
console.log(timezone);
},
elementId: "custom-selector-element",
position: "top",
});
ianaTimezoneToHumanReadble
import { ianaTimezoneToHumanReadable } from "@neetohq/timezones";
ianaTimezoneToHumanReadable("Asia/Calcutta") // => Indian Standard Time
ianaTimezoneToHumanReadable("America/New_York") // => Eastern Standard Time
ianaTimezoneToHumanReadable("Europe/Berlin") // => Central Standard Time
Development
Clone the repo
git clone [email protected]:neetohq/neeto-timezones.git
cd neeto-timezones/js
pnpm install
pnpm dev
Publishing to npm
- Bump
package.json
version - Commit and push
pnpm build && pnpm publish