|
1 |
| -const EU_LOCALES = [ |
2 |
| - 'bg-bg', // Bulgarian (Bulgaria) |
3 |
| - 'cs-cz', // Czech (Czech Republic) |
4 |
| - 'cy-gb', // Welsh (United Kingdom) |
5 |
| - 'da-dk', // Danish (Denmark) |
6 |
| - 'de-at', // German (Austria) |
7 |
| - 'de-ch', // German (Switzerland) |
8 |
| - 'de-de', // German (Germany) |
9 |
| - 'el-gr', // Greek (Greece) |
10 |
| - 'en-gb', // English (United Kingdom) |
11 |
| - 'en-ie', // English (Ireland) |
12 |
| - 'et-ee', // Estonian (Estonia) |
13 |
| - 'fi-fi', // Finnish (Finland) |
14 |
| - 'fr-be', // French (Belgium) |
15 |
| - 'fr-ch', // French (Switzerland) |
16 |
| - 'fr-fr', // French (France) |
17 |
| - 'ga-ie', // Irish (Ireland) |
18 |
| - 'hr-hr', // Croatian (Croatia) |
19 |
| - 'hu-hu', // Hungarian (Hungary) |
20 |
| - 'is-is', // Icelandic (Iceland) |
21 |
| - 'it-ch', // Italian (Switzerland) |
22 |
| - 'it-it', // Italian (Italy) |
23 |
| - 'lb-lu', // Luxembourgish (Luxembourg) |
24 |
| - 'lt-lt', // Lithuanian (Lithuania) |
25 |
| - 'lv-lv', // Latvian (Latvia) |
26 |
| - 'mk-mk', // Macedonian (North Macedonia) |
27 |
| - 'mt-mt', // Maltese (Malta) |
28 |
| - 'nl-be', // Dutch (Belgium) |
29 |
| - 'nl-nl', // Dutch (Netherlands) |
30 |
| - 'no-no', // Norwegian (Norway) |
31 |
| - 'pl-pl', // Polish (Poland) |
32 |
| - 'pt-pt', // Portuguese (Portugal) |
33 |
| - 'ro-ro', // Romanian (Romania) |
34 |
| - 'ru-ru', // Russian (Russia) |
35 |
| - 'sk-sk', // Slovak (Slovakia) |
36 |
| - 'sl-si', // Slovenian (Slovenia) |
37 |
| - 'sr-rs', // Serbian (Serbia) |
38 |
| - 'sv-se', // Swedish (Sweden) |
39 |
| - 'uk-ua' // Ukrainian (Ukraine) |
40 |
| -] |
41 |
| - |
42 |
| -const OPTED_IN_LOCALES = [...EU_LOCALES] |
43 |
| - |
44 | 1 | const userHasNotOptedOutOfPreview = (): boolean => {
|
45 | 2 | const prefersOldBrowser = localStorage.getItem('prefersOldBrowser')
|
46 | 3 | const doesPreferQuery = prefersOldBrowser === 'false'
|
47 | 4 | return doesPreferQuery || prefersOldBrowser === null
|
48 | 5 | }
|
49 | 6 |
|
50 |
| -export const optedInByRegion = (): boolean => { |
51 |
| - return ( |
52 |
| - OPTED_IN_LOCALES.includes(navigator.language.toLowerCase()) && |
53 |
| - userHasNotOptedOutOfPreview() |
54 |
| - ) |
| 7 | +export const optedInByUtcOffset = (): boolean => { |
| 8 | + const utcOffset = new Date().getTimezoneOffset() |
| 9 | + // UTC offset of -120 minutes (2 hours) e.g. CEST to 0 minutes (0 hours) |
| 10 | + const utcOffsetIsOptedIn = utcOffset >= -120 && utcOffset <= 0 |
| 11 | + return utcOffsetIsOptedIn && userHasNotOptedOutOfPreview() |
55 | 12 | }
|
0 commit comments