From 4d7862ef4c140afe230323248f8395cfa5c580e9 Mon Sep 17 00:00:00 2001 From: 0Pranav Date: Wed, 18 Dec 2019 16:27:16 +0530 Subject: [PATCH] fix: defualt timezone not getting selected --- erpnext/www/book_appointment/index.js | 9 ++------- erpnext/www/book_appointment/index.py | 14 ++------------ 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/erpnext/www/book_appointment/index.js b/erpnext/www/book_appointment/index.js index c8dd5013d5c..44f52ff6690 100644 --- a/erpnext/www/book_appointment/index.js +++ b/erpnext/www/book_appointment/index.js @@ -24,20 +24,15 @@ async function get_global_variables() { } function setup_timezone_selector() { - /** - * window.timezones is a dictionary with the following structure - * { IANA name: Pretty name} - * For example : { Asia/Kolkata : "India Time - Asia/Kolkata"} - */ let timezones_element = document.getElementById('appointment-timezone'); let offset = new Date().getTimezoneOffset(); - Object.keys(window.timezones).forEach((timezone) => { + window.timezones.forEach((timezone) => { let opt = document.createElement('option'); opt.value = timezone; if (timezone == moment.tz.guess()) { opt.selected = true; } - opt.innerHTML = window.timezones[timezone] + opt.innerHTML = timezone timezones_element.appendChild(opt) }); } diff --git a/erpnext/www/book_appointment/index.py b/erpnext/www/book_appointment/index.py index 5b60dd5e7b7..3382dabf512 100644 --- a/erpnext/www/book_appointment/index.py +++ b/erpnext/www/book_appointment/index.py @@ -25,18 +25,8 @@ def get_appointment_settings(): @frappe.whitelist(allow_guest=True) def get_timezones(): - from babel.dates import get_timezone, get_timezone_name, Locale - from frappe.utils.momentjs import get_all_timezones - - translated_dict = {} - locale = Locale.parse(frappe.local.lang, sep="-") - - for tz in get_all_timezones(): - timezone_name = get_timezone_name(get_timezone(tz), locale=locale, width='short') - if timezone_name: - translated_dict[tz] = timezone_name + ' - ' + tz - - return translated_dict + import pytz + return pytz.all_timezones @frappe.whitelist(allow_guest=True) def get_appointment_slots(date, timezone):