eventalapp / evental

Open source event management software
https://evental.app
GNU Affero General Public License v3.0
24 stars 1 forks source link

Unable to create event in some timezones #3

Open KartikSoneji opened 1 year ago

KartikSoneji commented 1 year ago

The timezone validator is defined as an enum of the values from shared/utils/const.ts. https://github.com/eventalapp/evental/blob/2d788960a1b685561f50885ea736ab92eb79eee5/shared/utils/schema.ts#L25-L26

But if the current timezone is missing from the timezone list then trying to create an event from the frontend fails validation. There is no input element to display the error against and the failure callback is not implemented in the CreateEventForm component, so the validation failue is not even logged to the console. This makes it impossible to create an event from the frontend for some timezones. https://github.com/eventalapp/evental/blob/2d788960a1b685561f50885ea736ab92eb79eee5/web/components/events/CreateEventForm.tsx#L47-L51

The ECMA spec for timezones states that the timezones are from the IANA database (https://www.iana.org/time-zones). shared/utils/const.ts is missing around 80 or so timezones from the database. A few examples are Asia/Kuwait, Asia/Muscat, Europe/Isle_of_Man, Europe/Andorra, Europe/Kyiv

Additionally, the value returned may not always be standards compliant. For example, Chrome returns Asia/Calcutta instead of Asia/Kolkata. In the meanwhile, a dropdown or similar should be implemented to allow users to create events. Related: #2

KartikSoneji commented 1 year ago

The following diff updates constants.ts with the latest IANA list, but migrations need to be implemented for renamed timezones:

Current Name New Name
America/Godthab America/Nuuk
Australia/Currie Australia/Hobart
Europe/Kiev Europe/Kyiv
Europe/Uzhgorod Europe/Kyiv
Europe/Zaporozhye Europe/Kyiv
Pacific/Enderbury Pacific/Kanton
diff --git a/shared/utils/const.ts b/shared/utils/const.ts
index 276668d..9a4d9ad 100644
--- a/shared/utils/const.ts
+++ b/shared/utils/const.ts
@@ -46,0 +47,2 @@ export const timeZoneList = [
+   'America/Antigua',
+   'America/Anguilla',
@@ -48,0 +51,2 @@ export const timeZoneList = [
+   'Africa/Luanda',
+   'Antarctica/McMurdo',
@@ -75 +78,0 @@ export const timeZoneList = [
-   'Australia/Currie',
@@ -84,0 +88,2 @@ export const timeZoneList = [
+   'America/Aruba',
+   'Europe/Mariehamn',
@@ -85,0 +91 @@ export const timeZoneList = [
+   'Europe/Sarajevo',
@@ -88,0 +95 @@ export const timeZoneList = [
+   'Africa/Ouagadougou',
@@ -89,0 +97,4 @@ export const timeZoneList = [
+   'Asia/Bahrain',
+   'Africa/Bujumbura',
+   'Africa/Porto-Novo',
+   'America/St_Barthelemy',
@@ -92,0 +104 @@ export const timeZoneList = [
+   'America/Kralendijk',
@@ -110,0 +123 @@ export const timeZoneList = [
+   'Africa/Gaborone',
@@ -138 +150,0 @@ export const timeZoneList = [
-   'America/Vancouver',
@@ -140,0 +153 @@ export const timeZoneList = [
+   'America/Vancouver',
@@ -141,0 +155,4 @@ export const timeZoneList = [
+   'Africa/Kinshasa',
+   'Africa/Lubumbashi',
+   'Africa/Bangui',
+   'Africa/Brazzaville',
@@ -147,0 +165 @@ export const timeZoneList = [
+   'Africa/Douala',
@@ -159,0 +178,2 @@ export const timeZoneList = [
+   'Europe/Busingen',
+   'Africa/Djibouti',
@@ -160,0 +181 @@ export const timeZoneList = [
+   'America/Dominica',
@@ -167,0 +189 @@ export const timeZoneList = [
+   'Africa/Asmara',
@@ -170,0 +193 @@ export const timeZoneList = [
+   'Africa/Addis_Ababa',
@@ -178,0 +202 @@ export const timeZoneList = [
+   'Africa/Libreville',
@@ -179,0 +204 @@ export const timeZoneList = [
+   'America/Grenada',
@@ -181,0 +207 @@ export const timeZoneList = [
+   'Europe/Guernsey',
@@ -184 +210 @@ export const timeZoneList = [
-   'America/Godthab',
+   'America/Nuuk',
@@ -187,0 +214,4 @@ export const timeZoneList = [
+   'Africa/Banjul',
+   'Africa/Conakry',
+   'America/Guadeloupe',
+   'Africa/Malabo',
@@ -195,0 +226 @@ export const timeZoneList = [
+   'Europe/Zagreb',
@@ -203,0 +235 @@ export const timeZoneList = [
+   'Europe/Isle_of_Man',
@@ -209,0 +242 @@ export const timeZoneList = [
+   'Europe/Jersey',
@@ -214,0 +248 @@ export const timeZoneList = [
+   'Asia/Phnom_Penh',
@@ -216 +250 @@ export const timeZoneList = [
-   'Pacific/Enderbury',
+   'Pacific/Kanton',
@@ -217,0 +252,2 @@ export const timeZoneList = [
+   'Indian/Comoro',
+   'America/St_Kitts',
@@ -219,0 +256,2 @@ export const timeZoneList = [
+   'Asia/Kuwait',
+   'America/Cayman',
@@ -226,0 +265 @@ export const timeZoneList = [
+   'Asia/Vientiane',
@@ -227,0 +267,2 @@ export const timeZoneList = [
+   'America/St_Lucia',
+   'Europe/Vaduz',
@@ -229,0 +271 @@ export const timeZoneList = [
+   'Africa/Maseru',
@@ -236,0 +279,3 @@ export const timeZoneList = [
+   'Europe/Podgorica',
+   'America/Marigot',
+   'Indian/Antananarivo',
@@ -238,0 +284,2 @@ export const timeZoneList = [
+   'Europe/Skopje',
+   'Africa/Bamako',
@@ -243,0 +291 @@ export const timeZoneList = [
+   'Pacific/Saipan',
@@ -244,0 +293,2 @@ export const timeZoneList = [
+   'Africa/Nouakchott',
+   'America/Montserrat',
@@ -247,0 +298 @@ export const timeZoneList = [
+   'Africa/Blantyre',
@@ -263,0 +315 @@ export const timeZoneList = [
+   'Africa/Niamey',
@@ -273,0 +326 @@ export const timeZoneList = [
+   'Asia/Muscat',
@@ -302 +354,0 @@ export const timeZoneList = [
-   'Europe/Astrakhan',
@@ -303,0 +356 @@ export const timeZoneList = [
+   'Europe/Astrakhan',
@@ -324,0 +378 @@ export const timeZoneList = [
+   'Africa/Kigali',
@@ -330,0 +385,8 @@ export const timeZoneList = [
+   'Atlantic/St_Helena',
+   'Europe/Ljubljana',
+   'Arctic/Longyearbyen',
+   'Europe/Bratislava',
+   'Africa/Freetown',
+   'Europe/San_Marino',
+   'Africa/Dakar',
+   'Africa/Mogadishu',
@@ -334,0 +397 @@ export const timeZoneList = [
+   'America/Lower_Princes',
@@ -335,0 +399 @@ export const timeZoneList = [
+   'Africa/Mbabane',
@@ -338,0 +403 @@ export const timeZoneList = [
+   'Africa/Lome',
@@ -350,3 +415,4 @@ export const timeZoneList = [
-   'Europe/Kiev',
-   'Europe/Uzhgorod',
-   'Europe/Zaporozhye',
+   'Africa/Dar_es_Salaam',
+   'Europe/Kyiv',
+   'Africa/Kampala',
+   'Pacific/Midway',
@@ -385,0 +452,2 @@ export const timeZoneList = [
+   'Europe/Vatican',
+   'America/St_Vincent',
@@ -386,0 +455,2 @@ export const timeZoneList = [
+   'America/Tortola',
+   'America/St_Thomas',
@@ -391 +461,5 @@ export const timeZoneList = [
-   'Africa/Johannesburg'
+   'Asia/Aden',
+   'Indian/Mayotte',
+   'Africa/Johannesburg',
+   'Africa/Lusaka',
+   'Africa/Harare'