Created
August 18, 2021 04:59
-
-
Save mgd020/50024252081916d8ef434d2b84131424 to your computer and use it in GitHub Desktop.
is the user in the EU
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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