Skip to content

Instantly share code, notes, and snippets.

@mgd020
Created August 18, 2021 04:59
Show Gist options
  • Save mgd020/50024252081916d8ef434d2b84131424 to your computer and use it in GitHub Desktop.
Save mgd020/50024252081916d8ef434d2b84131424 to your computer and use it in GitHub Desktop.
is the user in the EU
isEu = function() {
var euCountryCodes = new Set(['be', 'el', 'lt', 'pt', 'bg', 'es', 'lu', 'ro', 'cz', 'fr', 're', 'gp', 'mq', 'gf', 'yt', 'bl', 'mf', 'pm', 'wf', 'pf', 'nc', 'hu', 'si', 'dk', 'fo', 'gl', 'hr', 'mt', 'sk', 'de', 'it', 'nl', 'aw', 'cw', 'sx', 'fi', 'ax', 'ee', 'cy', 'at', 'se', 'ie', 'lv', 'pl', 'uk', 'gb', 'ai', 'bm', 'io', 'vg', 'ky', 'fk', 'gi', 'ms', 'pn', 'sh', 'tc', 'gg', 'je', 'im']);
return function isEu() {
return (
Intl.DateTimeFormat().resolvedOptions().timeZone.startsWith('Europe/') ||
euCountryCodes.has((navigator.userLanguage || navigator.language).slice(0, 2))
);
}
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment