# timezone-picker
timezone-picker is the plugin to select and get timezone value of selected area(country) from WorldMap.
[![NPM version](https://badge.fury.io/js/timezone-picker.svg)](https://www.npmjs.com/package/timezone-picker)
[![NPM Dependency](https://david-dm.org/kevalbhatt/timezone-picker.svg)](https://www.npmjs.com/package/timezone-picker)
[![](https://data.jsdelivr.com/v1/package/npm/timezone-picker/badge)](https://www.jsdelivr.com/package/npm/timezone-picker)
[![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php)
[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)]()
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/kevalbhatt/timezone-picker/issues)
[![HitCount](http://hits.dwyl.com/kevalbhatt/timezone-picker.svg)](http://github.com/kevalbhatt/timezone-picker)
### Live Demo: http://kevalbhatt.github.io/timezone-picker/
---------------------
![Imgur](https://i.imgur.com/YrGdPv2.png)
# Dependency
---------------------
* moment-timezone
* jquery
* select2 (optional)
# Installation
---------------------
### Use package Using npm
```sh
npm install --save timezone-picker
```
or
### Use package Using CDN
```html
```
Include the following lines of code in the section of your HTML.
```html
```
# Usage
---------------------
## Select any dom element where you want to create the map.
```js
$(selector).timezonePicker();
```
## defaultValue
Set a custom value on load
If defaultValue is null then system timezone is selected
* ### Select value based on zonename.
```js
$(selector).timezonePicker({ defaultValue: { value: "EAT", attribute: "zonename" }});
```
* ### Select value based on country code.
```js
$(selector).timezonePicker({ defaultValue: { value: "IN", attribute: "country" }});
```
* ### Select value based on timezone.
```js
$(selector).timezonePicker({ defaultValue: { value: "Asia/Calcutta", attribute: "timezone" }});
```
* ### Select value based on offset.
```js
$(selector).timezonePicker({ defaultValue: { value: "5.5", attribute: "offset" }});
```
## quickLink
You can create custom shortcuts link using quickLink options.
```js
$(selector).timezonePicker({
quickLink: [{
"IST": "IST",
"LONDON": "Europe/London"
}]
});
```
* "LONDON": This key is used as a display string for shortcut button.
* "Europe/London": This value is used when user click on a button and based on value, map is highlighted
Example:
You can pass following value.
* **timezone** : Europe/London
* **zonename** : GMT
* **country code** : GB
```js
$(selector).timezonePicker({
quickLink: [{
"LONDON1": "Europe/London"
}]
});
$(selector).timezonePicker({
quickLink: [{
"LONDON2": "GB"
}]
});
$(selector).timezonePicker({
quickLink: [{
"LONDON3": "GMT"
}]
});
$(selector).timezonePicker({
quickLink: [{
"GMT": "GMT"
}]
});
```
## hoverText
```js
$(selector).timezonePicker({
hoverText: function(e, data){
return (data.timezone + " (" + data.zonename + ")");
}
});
```
## quickLinkClass
Class name for the quickLink container.
```js
$(selector).timezonePicker({
quickLinkClass: "quick-class"
});
```
**Output**
```diff
+
```
## selectClass
Class name for the country drop-down.
```js
$('body').timezonePicker({
selectClass: "select-class"
});
```
**Output**
```diff
+
```
## filterBoxClass
Class name for the filter box container.
```js
$('body').timezonePicker({
filterBoxClass: "filter-class"
});
```
**Output**
```diff
+
```
## hoverTextClass
Class name for the hover text container.
```js
$('body').timezonePicker({
hoverTextClass: "hover-class"
});
```
**Output**
```diff
+
```
# Options
---------------------
| Parameter | Type | Default | Description |
| :---------|:---- |:--------|:----------- |
| **width** | `Number` | `500` | width of map |
| **height** | `Number` | `250` | height of map |
| [**defaultValue**](#defaultvalue) | `Object` | System timezone | Set custome value on load `{ value: "EAT", attribute: "zonename" }` |
| [**quickLink**](#quicklink) | `Array