Timezone Plugin
Add a timezone selector dropdown to the timepicker. Display-only feature - does not convert times automatically.
The selector is a select-only combobox. Focus it with Tab, open it with Enter, Space or the arrow keys, and type letters to jump to the next timezone that starts with them.
Basic Timezone Selector
#With Default Timezone
#Custom Timezone List
#Custom Label
#Extend the Built-in List
#The plugin entry exports DEFAULT_TIMEZONES, the list the selector shows by default, and getTimezoneList(), which returns { id, label, offset } for each ID the browser knows. Spread the default list to add a zone. New in 4.7.0.
index.ts
import { TimepickerUI, PluginRegistry } from 'timepicker-ui';import {TimezonePlugin,getTimezoneList,DEFAULT_TIMEZONES} from 'timepicker-ui/plugins/timezone';PluginRegistry.register(TimezonePlugin);const list = [...DEFAULT_TIMEZONES, 'Europe/Warsaw'];const zones = getTimezoneList(list);const picker = new TimepickerUI(input, {timezone: {enabled: true,default: 'Europe/Warsaw',list}});picker.create();
Default Not in the List
#A timezone.default that is not in the list falls back to the browser timezone, or the first entry, and emits an error event once. New in 4.7.0.
index.ts
const picker = new TimepickerUI(input, {timezone: { enabled: true, default: 'Europe/Warsaw' }});picker.create();picker.on('error', (data) => {console.warn(data.error);// timezone.default "Europe/Warsaw" is not in the timezone list, using "Europe/Paris"});