fix:CityNotShownInOption (#17064)
Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
1 parent
0949bbf167
commit
14ae664941
10 files changed
+104
-219
No files matched your search
@@ -1,64 +0,0 @@
|
||||
{
|
||||
"timezones": [
|
||||
{
|
||||
"name": "Eastern Time - US & Canada",
|
||||
"identifier": "America/New_York"
|
||||
},
|
||||
{
|
||||
"name": "Pacific Time - US & Canada",
|
||||
"identifier": "America/Los_Angeles"
|
||||
},
|
||||
{
|
||||
"name": "Central Time - US & Canada",
|
||||
"identifier": "America/Chicago"
|
||||
},
|
||||
{
|
||||
"name": "Mountain Time - US & Canada",
|
||||
"identifier": "America/Denver"
|
||||
},
|
||||
{
|
||||
"name": "Atlantic Time - Canada",
|
||||
"identifier": "America/Halifax"
|
||||
},
|
||||
{
|
||||
"name": "Eastern European Time",
|
||||
"identifier": "Europe/Bucharest"
|
||||
},
|
||||
{
|
||||
"name": "Central European Time",
|
||||
"identifier": "Europe/Berlin"
|
||||
},
|
||||
{
|
||||
"name": "Western European Time",
|
||||
"identifier": "Europe/London"
|
||||
},
|
||||
{
|
||||
"name": "Australian Eastern Time",
|
||||
"identifier": "Australia/Sydney"
|
||||
},
|
||||
{
|
||||
"name": "Japan Standard Time",
|
||||
"identifier": "Asia/Tokyo"
|
||||
},
|
||||
{
|
||||
"name": "India Standard Time",
|
||||
"identifier": "Asia/Kolkata"
|
||||
},
|
||||
{
|
||||
"name": "Gulf Standard Time",
|
||||
"identifier": "Asia/Dubai"
|
||||
},
|
||||
{
|
||||
"name": "South Africa Standard Time",
|
||||
"identifier": "Africa/Johannesburg"
|
||||
},
|
||||
{
|
||||
"name": "Brazil Time",
|
||||
"identifier": "America/Sao_Paulo"
|
||||
},
|
||||
{
|
||||
"name": "Hawaii-Aleutian Standard Time",
|
||||
"identifier": "Pacific/Honolulu"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import * as additionalTimezones from "./additionalTimezones.json";
|
||||
|
||||
export interface Timezone {
|
||||
name: string;
|
||||
identifier: string;
|
||||
}
|
||||
|
||||
export const timezones: Timezone[] = additionalTimezones.timezones;
|
||||
|
||||
export default additionalTimezones;
|
||||
@@ -0,0 +1,31 @@
|
||||
import { cityMapping as allCities } from "city-timezones";
|
||||
|
||||
export type CityTimezones = Awaited<ReturnType<typeof cityTimezonesHandler>>;
|
||||
|
||||
export const cityTimezonesHandler = async () => {
|
||||
/**
|
||||
* Filter out all cities that have the same "city" key and only use the one with the highest population.
|
||||
* This way we return a new array of cities without running the risk of having more than one city
|
||||
* with the same name on the dropdown and prevent users from mistaking the time zone of the desired city.
|
||||
*/
|
||||
const topPopulatedCities: { [key: string]: { city: string; timezone: string; pop: number } } = {};
|
||||
allCities.forEach((city) => {
|
||||
const cityPopulationCount = city.pop;
|
||||
if (
|
||||
topPopulatedCities[city.city]?.pop === undefined ||
|
||||
cityPopulationCount > topPopulatedCities[city.city].pop
|
||||
) {
|
||||
topPopulatedCities[city.city] = { city: city.city, timezone: city.timezone, pop: city.pop };
|
||||
}
|
||||
});
|
||||
const uniqueCities = Object.values(topPopulatedCities);
|
||||
/** Add specific overries in here */
|
||||
uniqueCities.forEach((city) => {
|
||||
if (city.city === "London") city.timezone = "Europe/London";
|
||||
if (city.city === "Londonderry") city.city = "London";
|
||||
});
|
||||
|
||||
return uniqueCities;
|
||||
};
|
||||
|
||||
export default cityTimezonesHandler;
|
||||
Reference in new issue
Block a user