
Security News
NVD Quietly Sweeps 100K+ CVEs Into a “Deferred” Black Hole
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
timezone-select-js
Advanced tools
Timezone Select JS - Datasource from Wikipedia - no DateTime dependences
React
, Angular
, VueJS
...Deprecated
timezones that linked to other, such as Asia/Saigon (Vietnam)
, Asia/Chongqing (China)
, Europe/Belfast (England)
, Japan (Japan)
, Singapore (Singapore)
...npm i timezone-select-js
clientTz
America/New_York
Japan
it will return Asia/Tokyo
.findTzByKey
Return raw timezone item
{
country: '',
name: 'Singapore',
status: 'Deprecated',
offset: '+08:00',
link: 'Asia/Singapore'
}
findTzByName
Return grouped timezone item
{
value: 'Asia/Singapore'
label: '(GMT+08:00) Singapore'
country: 'SG'
offset: '+08:00'
included: 'Asia/Singapore, Singapore'
}
listTz
Return list of timezone that grouped by country and offset including deprecated timezone:
[
...,
{
value: 'America/Los_Angeles'
label: '(GMT-08:00) Los Angeles'
country: 'US'
offset: '-08:00'
included: 'America/Los_Angeles, PST8PDT, US/Pacific'
},
{
value: 'Asia/Tokyo'
label: '(GMT+09:00) Tokyo'
country: 'JP'
offset: '+09:00'
included: 'Asia/Tokyo, Japan'
},
...
]
tzRawData
Return raw data source, anyone can use this data for different usage
[
...,
{
country: 'US',
name: 'America/Los_Angeles',
status: 'Canonical',
offset: '−08:00',
link: ''
},
{
country: '',
name: 'Japan',
status: 'Deprecated',
offset: '+09:00',
link: 'Asia/Tokyo'
},
...
]
TimezoneSelect
Look at the example of usage below
import { listTz, clientTz, findTzByName } from 'timezone-select-js';
import React, { useMemo } from 'react';
import Select from 'react-select';
const TimezoneSelect = ({
value,
onBlur,
onChange,
labelStyle = 'original',
...props
}) => {
const getOptions = useMemo(() => {
return listTz();
}, [labelStyle]);
const handleChange = tz => {
onChange && onChange(tz);
};
const constructTz = (data) => {
return typeof data === 'string' ? findTzByName(data, getOptions) : data;
};
return (
<Select
value={constructTz(value)}
onChange={handleChange}
options={getOptions}
onBlur={onBlur}
{...props}
/>
)
}
const App = () => {
const [selectedTimezone, setSelectedTimezone] = useState(clientTz());
return (
<div className='app'>
<h2>Timezone Select</h2>
<blockquote>Please make a selection</blockquote>
<div>
<TimezoneSelect
value={selectedTimezone}
onChange={setSelectedTimezone}
/>
</div>
</div>
)
}
const rootElement = document.getElementById('root')
ReactDOM.render(<App />, rootElement)
import { listTz, clientTz } from 'timezone-select-js';
import {NgSelectModule, NgOption} from '@ng-select/ng-select';
@Component({...})
export class ExampleComponent {
timezones = listTz();
selectedTimezone = clientTz();
}
<!--Using ng-option and for loop-->
<ng-select [(ngModel)]="selectedTimezone">
<ng-option *ngFor="let tz of timezones" [value]="tz.value">{{tz.label}}</ng-option>
</ng-select>
<!--Or using items input-->
<ng-select [items]="timezones"
bindLabel="label"
bindValue="value"
[(ngModel)]="selectedTimezone">
</ng-select>
import { listTz, clientTz } from 'timezone-select-js';
new Vue({
el: '...',
template: '...',
data: {
selected: clientTz(),
timezones: listTz();
}
})
<select v-model="selected">
<option v-for="tz in timezones" :selected="selected === tz.value" v-bind:value="tz.value">{{ tz.label }}</option>
</select>
Pull requests are always welcome!
FAQs
Timezone Select JS - Datasource from Wikipedia - no DateTime dependences
We found that timezone-select-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
Research
Security News
Lazarus-linked threat actors expand their npm malware campaign with new RAT loaders, hex obfuscation, and over 5,600 downloads across 11 packages.
Security News
Safari 18.4 adds support for Iterator Helpers and two other TC39 JavaScript features, bringing full cross-browser coverage to key parts of the ECMAScript spec.