Skip to content

Commit

Permalink
Since moment-timezone was added, there's no need for zone name list
Browse files Browse the repository at this point in the history
  • Loading branch information
Gnito committed Sep 24, 2019
1 parent 6dfef51 commit 1b46043
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 700 deletions.
189 changes: 0 additions & 189 deletions scripts/parse-iana-timezones.js

This file was deleted.

20 changes: 9 additions & 11 deletions src/components/FieldTimeZoneSelect/FieldTimeZoneSelect.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import React from 'react';
import { array, string } from 'prop-types';
import { string } from 'prop-types';
import { getTimeZoneNames } from '../../util/dates';
import { FieldSelect } from '../../components';

// You can update timezone keys if needed by running timezone script (aka parse-iana-timezones.js).
// We have a script that can generate keys from moment-timezone data format
// https://github.com/moment/moment-timezone/tree/develop/data/unpacked
// Check the instructions from generated file: iana-2019b-keys.js
import timezones from './iana-2019b-keys.js';

const FieldTimeZoneSelect = props => {

// IANA database contains irrelevant time zones too.
const relevantZonesPattern = new RegExp(
'^(Africa|America|Antarctica|Asia|Atlantic|Australia|Europe|Indian|Pacific)'
);

return (
<FieldSelect {...props}>
<option disabled value="">
Pick something...
</option>
{timezones.map(tz => (
{getTimeZoneNames(relevantZonesPattern).map(tz => (
<option key={tz} value={tz}>
{tz}
</option>
Expand All @@ -28,7 +29,6 @@ FieldTimeZoneSelect.defaultProps = {
className: null,
id: null,
label: null,
timezones: timezones,
};

FieldTimeZoneSelect.propTypes = {
Expand All @@ -40,8 +40,6 @@ FieldTimeZoneSelect.propTypes = {
id: string,
label: string,
name: string.isRequired,

timezones: array,
};

export default FieldTimeZoneSelect;
Loading

0 comments on commit 1b46043

Please sign in to comment.