-
Notifications
You must be signed in to change notification settings - Fork 374
/
Copy pathFieldTimeZoneSelect.js
44 lines (38 loc) · 1.17 KB
/
FieldTimeZoneSelect.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import React from 'react';
import { string } from 'prop-types';
import { getTimeZoneNames } from '../../util/dates';
import { FieldSelect } from '../../components';
const FieldTimeZoneSelect = props => {
// IANA database contains irrelevant time zones too.
const relevantZonesPattern = new RegExp(
'^(Africa|America(?!/(Argentina/ComodRivadavia|Knox_IN|Nuuk))|Antarctica(?!/(DumontDUrville|McMurdo))|Asia(?!/Qostanay)|Atlantic|Australia(?!/(ACT|LHI|NSW))|Europe|Indian|Pacific)'
);
return (
<FieldSelect {...props}>
<option disabled value="">
Pick something...
</option>
{getTimeZoneNames(relevantZonesPattern).map(tz => (
<option key={tz} value={tz}>
{tz}
</option>
))}
</FieldSelect>
);
};
FieldTimeZoneSelect.defaultProps = {
rootClassName: null,
className: null,
id: null,
label: null,
};
FieldTimeZoneSelect.propTypes = {
rootClassName: string,
className: string,
// Label is optional, but if it is given, an id is also required so
// the label can reference the input in the `for` attribute
id: string,
label: string,
name: string.isRequired,
};
export default FieldTimeZoneSelect;