timezone-selector with moment js not working in IE11

Viewed 49

//TimeZone

/*const z_t = (s) => {
    if (i18n !== void 0 && i18n[s]) {
        return i18n[s];
    }

    return s;
};*/
const z_t = function(s) {
    if (i18n !== void 0 && i18n[s]) {
        return i18n[s];
    }

    return s;
};
const timezones = [
    "Etc/GMT+12",
    "Pacific/Midway",
    "Pacific/Auckland",
    "Pacific/Tongatapu",
];

const i18n = {
    "Etc/GMT+12": "International Date Line West",
    "Pacific/Midway": "Midway Island, Samoa",
    "Pacific/Honolulu": "Hawaii",
    "Pacific/Tongatapu": "Nuku'alofa",
};

const selectorOptions = moment.tz
    .names()
    .filter((tz) => {
        return timezones.includes(tz);
    })
    .reduce((memo, tz) => {
        memo.push({
            name: tz,
            offset: moment.tz(tz).utcOffset(),
        });

        return memo;
    }, [])
    .sort((a, b) => {
        return a.offset - b.offset;
    })
    .reduce((memo, tz) => {
        const timezone = tz.offset ? moment.tz(tz.name).format("Z") : "";

        return memo.concat(
            `<option value="${tz.name}">(GMT${timezone}) ${z_t(tz.name)}</option>`
        );
    }, "");
let js_Selector = document.querySelector(".js-Selector");
console.log(js_Selector);
if (js_Selector) {
    js_Selector.innerHTML = selectorOptions;
    js_Selector.value = "Europe/Brussels";
    const event = new Event("change");
    js_Selector.dispatchEvent(event);
}

$(".js-Selector").select2();

I am using timezone-selector with moment js for selecting timezone.It works fine but on IE11 its not working.Its bcoz there are some arrow function in it.I tried correcting but it doesn't work.Since i am a newbie pls help me to solve this.Anyways thanks for the help in advance

0 Answers
Related