Skip to content

Instantly share code, notes, and snippets.

@joshwnj
Created January 9, 2019 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshwnj/ba991d4248448dea4a8495fe3c037fb2 to your computer and use it in GitHub Desktop.
Save joshwnj/ba991d4248448dea4a8495fe3c037fb2 to your computer and use it in GitHub Desktop.
const ct = require('countries-and-timezones')
const countries = ct.getAllCountries()
const flatten = (a) => a.reduce((acc, val) => acc.concat(val), [])
const unique = (a) => [...new Set(a)]
const combinations = Object.values(countries).map(country => {
const { id, name } = country
const zones = ct.getTimezonesForCountry(id)
return zones.map(({utcOffset, offsetStr }) => {
return {
id,
name,
utcOffset,
offsetStr
}
})
})
console.log(
unique(flatten(combinations).map(c => `${c.name} (${c.offsetStr})`))
)
[ 'Andorra (+01:00)',
'United Arab Emirates (+04:00)',
'Afghanistan (+04:30)',
'Antigua & Barbuda (-04:00)',
'Anguilla (-04:00)',
'Albania (+01:00)',
'Armenia (+04:00)',
'Angola (+01:00)',
'Antarctica (-03:00)',
'Antarctica (+05:00)',
'Antarctica (+07:00)',
'Antarctica (+08:00)',
'Antarctica (+06:00)',
'Antarctica (+10:00)',
'Antarctica (+03:00)',
'Antarctica (+00:00)',
'Antarctica (+13:00)',
'Argentina (-03:00)',
'Samoa (American) (-11:00)',
'Austria (+01:00)',
'Australia (+11:00)',
'Australia (+10:30)',
'Australia (+10:00)',
'Australia (+09:30)',
'Australia (+08:00)',
'Australia (+08:45)',
'Aruba (-04:00)',
'Åland Islands (+02:00)',
'Azerbaijan (+04:00)',
'Bosnia & Herzegovina (+01:00)',
'Barbados (-04:00)',
'Bangladesh (+06:00)',
'Belgium (+01:00)',
'Burkina Faso (+00:00)',
'Bulgaria (+02:00)',
'Bahrain (+03:00)',
'Burundi (+02:00)',
'Benin (+01:00)',
'St Barthelemy (-04:00)',
'Bermuda (-04:00)',
'Brunei (+08:00)',
'Bolivia (-04:00)',
'Caribbean Netherlands (-04:00)',
'Brazil (-02:00)',
'Brazil (-03:00)',
'Brazil (-04:00)',
'Brazil (-05:00)',
'Bahamas (-05:00)',
'Bhutan (+06:00)',
'Botswana (+02:00)',
'Belarus (+03:00)',
'Belize (-06:00)',
'Canada (-03:30)',
'Canada (-04:00)',
'Canada (-05:00)',
'Canada (-06:00)',
'Canada (-07:00)',
'Canada (-08:00)',
'Cocos (Keeling) Islands (+06:30)',
'Congo (Dem. Rep.) (+02:00)',
'Congo (Dem. Rep.) (+01:00)',
'Central African Rep. (+01:00)',
'Congo (Rep.) (+01:00)',
'Switzerland (+01:00)',
'Côte d\'Ivoire (+00:00)',
'Cook Islands (-10:00)',
'Chile (-03:00)',
'Chile (-05:00)',
'Cameroon (+01:00)',
'China (+08:00)',
'China (+06:00)',
'Colombia (-05:00)',
'Costa Rica (-06:00)',
'Cuba (-05:00)',
'Cape Verde (-01:00)',
'Curacao (-04:00)',
'Christmas Island (+07:00)',
'Cyprus (+02:00)',
'Czech Republic (+01:00)',
'Germany (+01:00)',
'Djibouti (+03:00)',
'Denmark (+01:00)',
'Dominica (-04:00)',
'Dominican Republic (-04:00)',
'Algeria (+01:00)',
'Ecuador (-05:00)',
'Ecuador (-06:00)',
'Estonia (+02:00)',
'Egypt (+02:00)',
'Western Sahara (+00:00)',
'Eritrea (+03:00)',
'Spain (+01:00)',
'Spain (+00:00)',
'Ethiopia (+03:00)',
'Finland (+02:00)',
'Fiji (+12:00)',
'Falkland Islands (-03:00)',
'Micronesia (+10:00)',
'Micronesia (+11:00)',
'Faroe Islands (+00:00)',
... 209 more items ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment