UNPKG

ngx-timezones

Version:

An Angular module for timezones (based on moment.js)

1,132 lines (1,120 loc) 48.4 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/forms'), require('moment-timezone'), require('rxjs/operators'), require('@angular/platform-browser/animations'), require('ngx-mat-select-search'), require('@angular/material/select'), require('@angular/material/form-field')) : typeof define === 'function' && define.amd ? define('ngx-timezones', ['exports', '@angular/core', '@angular/forms', 'moment-timezone', 'rxjs/operators', '@angular/platform-browser/animations', 'ngx-mat-select-search', '@angular/material/select', '@angular/material/form-field'], factory) : (global = global || self, factory(global['ngx-timezones'] = {}, global.ng.core, global.ng.forms, global.moment, global.rxjs.operators, global.ng.platformBrowser.animations, global.ngxMatSelectSearch, global.ng.material.select, global.ng.material.formField)); }(this, (function (exports, core, forms, moment, operators, animations, ngxMatSelectSearch, select, formField) { 'use strict'; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function () { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } function __param(paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); }; } function __metadata(metadataKey, metadataValue) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); } function __awaiter(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function () { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } var __createBinding = Object.create ? (function (o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } }); }) : (function (o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; }); function __exportStar(m, exports) { for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } function __values(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); } function __read(o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; } function __spread() { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; } function __spreadArrays() { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; } ; function __await(v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } function __asyncGenerator(thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), i, q = []; return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } } function __asyncDelegator(o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } } function __asyncValues(o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator], i; return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); } } function __makeTemplateObject(cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; } ; var __setModuleDefault = Object.create ? (function (o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function (o, v) { o["default"] = v; }; function __importStar(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; } function __importDefault(mod) { return (mod && mod.__esModule) ? mod : { default: mod }; } function __classPrivateFieldGet(receiver, privateMap) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return privateMap.get(receiver); } function __classPrivateFieldSet(receiver, privateMap, value) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to set private field on non-instance"); } privateMap.set(receiver, value); return value; } var countryZones = { AD: { name: 'Andorra', zones: ['Europe/Andorra'] }, AE: { name: 'United Arab Emirates', zones: ['Asia/Dubai'] }, AF: { name: 'Afghanistan', zones: ['Asia/Kabul'] }, AG: { name: 'Antigua & Barbuda', zones: ['America/Antigua'], }, AI: { name: 'Anguilla', zones: ['America/Anguilla'], }, AL: { name: 'Albania', zones: ['Europe/Tirane'] }, AM: { name: 'Armenia', zones: ['Asia/Yerevan'] }, AO: { name: 'Angola', zones: ['Africa/Lagos', 'Africa/Luanda'] }, AQ: { name: 'Antarctica', zones: [ 'Antarctica/Casey', 'Antarctica/Davis', 'Antarctica/DumontDUrville', 'Antarctica/Mawson', 'Antarctica/Palmer', 'Antarctica/Rothera', 'Antarctica/Syowa', 'Antarctica/Troll', 'Antarctica/Vostok', 'Pacific/Auckland', 'Antarctica/McMurdo', ], }, AR: { name: 'Argentina', zones: [ 'America/Argentina/Buenos_Aires', 'America/Argentina/Cordoba', 'America/Argentina/Salta', 'America/Argentina/Jujuy', 'America/Argentina/Tucuman', 'America/Argentina/Catamarca', 'America/Argentina/La_Rioja', 'America/Argentina/San_Juan', 'America/Argentina/Mendoza', 'America/Argentina/San_Luis', 'America/Argentina/Rio_Gallegos', 'America/Argentina/Ushuaia', ], }, AS: { name: 'Samoa (American)', zones: ['Pacific/Pago_Pago'] }, AT: { name: 'Austria', zones: ['Europe/Vienna'] }, AU: { name: 'Australia', zones: [ 'Australia/Lord_Howe', 'Antarctica/Macquarie', 'Australia/Hobart', 'Australia/Currie', 'Australia/Melbourne', 'Australia/Sydney', 'Australia/Broken_Hill', 'Australia/Brisbane', 'Australia/Lindeman', 'Australia/Adelaide', 'Australia/Darwin', 'Australia/Perth', 'Australia/Eucla', ], }, AW: { name: 'Aruba', zones: ['America/Curacao', 'America/Aruba'] }, AX: { name: 'Åland Islands', zones: ['Europe/Helsinki', 'Europe/Mariehamn'], }, AZ: { name: 'Azerbaijan', zones: ['Asia/Baku'] }, BA: { name: 'Bosnia & Herzegovina', zones: ['Europe/Belgrade', 'Europe/Sarajevo'], }, BB: { name: 'Barbados', zones: ['America/Barbados'] }, BD: { name: 'Bangladesh', zones: ['Asia/Dhaka'] }, BE: { name: 'Belgium', zones: ['Europe/Brussels'] }, BF: { name: 'Burkina Faso', zones: ['Africa/Abidjan', 'Africa/Ouagadougou'], }, BG: { name: 'Bulgaria', zones: ['Europe/Sofia'] }, BH: { name: 'Bahrain', zones: ['Asia/Qatar', 'Asia/Bahrain'] }, BI: { name: 'Burundi', zones: ['Africa/Maputo', 'Africa/Bujumbura'] }, BJ: { name: 'Benin', zones: ['Africa/Lagos', 'Africa/Porto-Novo'] }, BL: { name: 'St Barthelemy', zones: ['America/St_Barthelemy'], }, BM: { name: 'Bermuda', zones: ['Atlantic/Bermuda'] }, BN: { name: 'Brunei', zones: ['Asia/Brunei'] }, BO: { name: 'Bolivia', zones: ['America/La_Paz'] }, BQ: { name: 'Caribbean NL', zones: ['America/Curacao', 'America/Kralendijk'], }, BR: { name: 'Brazil', zones: [ 'America/Noronha', 'America/Belem', 'America/Fortaleza', 'America/Recife', 'America/Araguaina', 'America/Maceio', 'America/Bahia', 'America/Sao_Paulo', 'America/Campo_Grande', 'America/Cuiaba', 'America/Santarem', 'America/Porto_Velho', 'America/Boa_Vista', 'America/Manaus', 'America/Eirunepe', 'America/Rio_Branco', ], }, BS: { name: 'Bahamas', zones: ['America/Nassau'] }, BT: { name: 'Bhutan', zones: ['Asia/Thimphu'] }, BW: { name: 'Botswana', zones: ['Africa/Maputo', 'Africa/Gaborone'] }, BY: { name: 'Belarus', zones: ['Europe/Minsk'] }, BZ: { name: 'Belize', zones: ['America/Belize'] }, CA: { name: 'Canada', zones: [ 'America/St_Johns', 'America/Halifax', 'America/Glace_Bay', 'America/Moncton', 'America/Goose_Bay', 'America/Blanc-Sablon', 'America/Toronto', 'America/Nipigon', 'America/Thunder_Bay', 'America/Iqaluit', 'America/Pangnirtung', 'America/Atikokan', 'America/Winnipeg', 'America/Rainy_River', 'America/Resolute', 'America/Rankin_Inlet', 'America/Regina', 'America/Swift_Current', 'America/Edmonton', 'America/Cambridge_Bay', 'America/Yellowknife', 'America/Inuvik', 'America/Creston', 'America/Dawson_Creek', 'America/Fort_Nelson', 'America/Vancouver', 'America/Whitehorse', 'America/Dawson', ], }, CC: { name: 'Cocos (Keeling) Islands', zones: ['Indian/Cocos'] }, CD: { name: 'Congo (Dem. Rep.)', zones: [ 'Africa/Maputo', 'Africa/Lagos', 'Africa/Kinshasa', 'Africa/Lubumbashi', ], }, CF: { name: 'Central African Rep.', zones: ['Africa/Lagos', 'Africa/Bangui'], }, CG: { name: 'Congo (Rep.)', zones: ['Africa/Lagos', 'Africa/Brazzaville'], }, CH: { name: 'Switzerland', zones: ['Europe/Zurich'] }, CI: { name: "Côte d'Ivoire", zones: ['Africa/Abidjan'] }, CK: { name: 'Cook Islands', zones: ['Pacific/Rarotonga'] }, CL: { name: 'Chile', zones: ['America/Santiago', 'America/Punta_Arenas', 'Pacific/Easter'], }, CM: { name: 'Cameroon', zones: ['Africa/Lagos', 'Africa/Douala'] }, CN: { name: 'China', zones: ['Asia/Shanghai', 'Asia/Urumqi'] }, CO: { name: 'Colombia', zones: ['America/Bogota'] }, CR: { name: 'Costa Rica', zones: ['America/Costa_Rica'] }, CU: { name: 'Cuba', zones: ['America/Havana'] }, CV: { name: 'Cape Verde', zones: ['Atlantic/Cape_Verde'] }, CW: { name: 'Curaçao', zones: ['America/Curacao'] }, CX: { name: 'Christmas Island', zones: ['Indian/Christmas'] }, CY: { name: 'Cyprus', zones: ['Asia/Nicosia', 'Asia/Famagusta'] }, CZ: { name: 'Czech Republic', zones: ['Europe/Prague'] }, DE: { name: 'Germany', zones: ['Europe/Zurich', 'Europe/Berlin', 'Europe/Busingen'], }, DJ: { name: 'Djibouti', zones: ['Africa/Nairobi', 'Africa/Djibouti'] }, DK: { name: 'Denmark', zones: ['Europe/Copenhagen'] }, DM: { name: 'Dominica', zones: ['America/Dominica'], }, DO: { name: 'Dominican Republic', zones: ['America/Santo_Domingo'] }, DZ: { name: 'Algeria', zones: ['Africa/Algiers'] }, EC: { name: 'Ecuador', zones: ['America/Guayaquil', 'Pacific/Galapagos'], }, EE: { name: 'Estonia', zones: ['Europe/Tallinn'] }, EG: { name: 'Egypt', zones: ['Africa/Cairo'] }, EH: { name: 'Western Sahara', zones: ['Africa/El_Aaiun'] }, ER: { name: 'Eritrea', zones: ['Africa/Nairobi', 'Africa/Asmara'] }, ES: { name: 'Spain', zones: ['Europe/Madrid', 'Africa/Ceuta', 'Atlantic/Canary'], }, ET: { name: 'Ethiopia', zones: ['Africa/Nairobi', 'Africa/Addis_Ababa'], }, FI: { name: 'Finland', zones: ['Europe/Helsinki'] }, FJ: { name: 'Fiji', zones: ['Pacific/Fiji'] }, FK: { name: 'Falkland Islands', zones: ['Atlantic/Stanley'] }, FM: { name: 'Micronesia', zones: ['Pacific/Chuuk', 'Pacific/Pohnpei', 'Pacific/Kosrae'], }, FO: { name: 'Faroe Islands', zones: ['Atlantic/Faroe'] }, FR: { name: 'France', zones: ['Europe/Paris'] }, GA: { name: 'Gabon', zones: ['Africa/Lagos', 'Africa/Libreville'] }, GB: { name: 'Britain (UK)', zones: ['Europe/London'] }, GD: { name: 'Grenada', zones: ['America/Grenada'], }, GE: { name: 'Georgia', zones: ['Asia/Tbilisi'] }, GF: { name: 'French Guiana', zones: ['America/Cayenne'] }, GG: { name: 'Guernsey', zones: ['Europe/London', 'Europe/Guernsey'] }, GH: { name: 'Ghana', zones: ['Africa/Accra'] }, GI: { name: 'Gibraltar', zones: ['Europe/Gibraltar'] }, GL: { name: 'Greenland', zones: [ 'America/Nuuk', 'America/Danmarkshavn', 'America/Scoresbysund', 'America/Thule', ], }, GM: { name: 'Gambia', zones: ['Africa/Abidjan', 'Africa/Banjul'] }, GN: { name: 'Guinea', zones: ['Africa/Abidjan', 'Africa/Conakry'] }, GP: { name: 'Guadeloupe', zones: ['America/Guadeloupe'], }, GQ: { name: 'Equatorial Guinea', zones: ['Africa/Lagos', 'Africa/Malabo'], }, GR: { name: 'Greece', zones: ['Europe/Athens'] }, GS: { name: 'South Georgia & the South Sandwich Islands', zones: ['Atlantic/South_Georgia'], }, GT: { name: 'Guatemala', zones: ['America/Guatemala'] }, GU: { name: 'Guam', zones: ['Pacific/Guam'] }, GW: { name: 'Guinea-Bissau', zones: ['Africa/Bissau'] }, GY: { name: 'Guyana', zones: ['America/Guyana'] }, HK: { name: 'Hong Kong', zones: ['Asia/Hong_Kong'] }, HN: { name: 'Honduras', zones: ['America/Tegucigalpa'] }, HR: { name: 'Croatia', zones: ['Europe/Belgrade', 'Europe/Zagreb'] }, HT: { name: 'Haiti', zones: ['America/Port-au-Prince'] }, HU: { name: 'Hungary', zones: ['Europe/Budapest'] }, ID: { name: 'Indonesia', zones: ['Asia/Jakarta', 'Asia/Pontianak', 'Asia/Makassar', 'Asia/Jayapura'], }, IE: { name: 'Ireland', zones: ['Europe/Dublin'] }, IL: { name: 'Israel', zones: ['Asia/Jerusalem'] }, IM: { name: 'Isle of Man', zones: ['Europe/London', 'Europe/Isle_of_Man'], }, IN: { name: 'India', zones: ['Asia/Kolkata'] }, IO: { name: 'British Indian Ocean Territory', zones: ['Indian/Chagos'], }, IQ: { name: 'Iraq', zones: ['Asia/Baghdad'] }, IR: { name: 'Iran', zones: ['Asia/Tehran'] }, IS: { name: 'Iceland', zones: ['Atlantic/Reykjavik'] }, IT: { name: 'Italy', zones: ['Europe/Rome'] }, JE: { name: 'Jersey', zones: ['Europe/London', 'Europe/Jersey'] }, JM: { name: 'Jamaica', zones: ['America/Jamaica'] }, JO: { name: 'Jordan', zones: ['Asia/Amman'] }, JP: { name: 'Japan', zones: ['Asia/Tokyo'] }, KE: { name: 'Kenya', zones: ['Africa/Nairobi'] }, KG: { name: 'Kyrgyzstan', zones: ['Asia/Bishkek'] }, KH: { name: 'Cambodia', zones: ['Asia/Bangkok', 'Asia/Phnom_Penh'] }, KI: { name: 'Kiribati', zones: ['Pacific/Tarawa', 'Pacific/Enderbury', 'Pacific/Kiritimati'], }, KM: { name: 'Comoros', zones: ['Africa/Nairobi', 'Indian/Comoro'] }, KN: { name: 'St Kitts & Nevis', zones: ['America/St_Kitts'], }, KP: { name: 'Korea (North)', zones: ['Asia/Pyongyang'] }, KR: { name: 'Korea (South)', zones: ['Asia/Seoul'] }, KW: { name: 'Kuwait', zones: ['Asia/Riyadh', 'Asia/Kuwait'] }, KY: { name: 'Cayman Islands', zones: ['America/Panama', 'America/Cayman'], }, KZ: { name: 'Kazakhstan', zones: [ 'Asia/Almaty', 'Asia/Qyzylorda', 'Asia/Qostanay', 'Asia/Aqtobe', 'Asia/Aqtau', 'Asia/Atyrau', 'Asia/Oral', ], }, LA: { name: 'Laos', zones: ['Asia/Bangkok', 'Asia/Vientiane'] }, LB: { name: 'Lebanon', zones: ['Asia/Beirut'] }, LC: { name: 'St Lucia', zones: ['America/St_Lucia'], }, LI: { name: 'Liechtenstein', zones: ['Europe/Zurich', 'Europe/Vaduz'], }, LK: { name: 'Sri Lanka', zones: ['Asia/Colombo'] }, LR: { name: 'Liberia', zones: ['Africa/Monrovia'] }, LS: { name: 'Lesotho', zones: ['Africa/Johannesburg', 'Africa/Maseru'], }, LT: { name: 'Lithuania', zones: ['Europe/Vilnius'] }, LU: { name: 'Luxembourg', zones: ['Europe/Luxembourg'] }, LV: { name: 'Latvia', zones: ['Europe/Riga'] }, LY: { name: 'Libya', zones: ['Africa/Tripoli'] }, MA: { name: 'Morocco', zones: ['Africa/Casablanca'] }, MC: { name: 'Monaco', zones: ['Europe/Monaco'] }, MD: { name: 'Moldova', zones: ['Europe/Chisinau'] }, ME: { name: 'Montenegro', zones: ['Europe/Belgrade', 'Europe/Podgorica'], }, MF: { name: 'St Martin (French)', zones: ['America/Marigot'], }, MG: { name: 'Madagascar', zones: ['Africa/Nairobi', 'Indian/Antananarivo'], }, MH: { name: 'Marshall Islands', zones: ['Pacific/Majuro', 'Pacific/Kwajalein'], }, MK: { name: 'North Macedonia', zones: ['Europe/Belgrade', 'Europe/Skopje'], }, ML: { name: 'Mali', zones: ['Africa/Abidjan', 'Africa/Bamako'] }, MM: { name: 'Myanmar (Burma)', zones: ['Asia/Yangon'] }, MN: { name: 'Mongolia', zones: ['Asia/Ulaanbaatar', 'Asia/Hovd', 'Asia/Choibalsan'], }, MO: { name: 'Macau', zones: ['Asia/Macau'] }, MP: { name: 'Northern Mariana Islands', zones: ['Pacific/Guam', 'Pacific/Saipan'], }, MQ: { name: 'Martinique', zones: ['America/Martinique'] }, MR: { name: 'Mauritania', zones: ['Africa/Abidjan', 'Africa/Nouakchott'], }, MS: { name: 'Montserrat', zones: ['America/Montserrat'], }, MT: { name: 'Malta', zones: ['Europe/Malta'] }, MU: { name: 'Mauritius', zones: ['Indian/Mauritius'] }, MV: { name: 'Maldives', zones: ['Indian/Maldives'] }, MW: { name: 'Malawi', zones: ['Africa/Maputo', 'Africa/Blantyre'] }, MX: { name: 'Mexico', zones: [ 'America/Mexico_City', 'America/Cancun', 'America/Merida', 'America/Monterrey', 'America/Matamoros', 'America/Mazatlan', 'America/Chihuahua', 'America/Ojinaga', 'America/Hermosillo', 'America/Tijuana', 'America/Bahia_Banderas', ], }, MY: { name: 'Malaysia', zones: ['Asia/Kuala_Lumpur', 'Asia/Kuching'] }, MZ: { name: 'Mozambique', zones: ['Africa/Maputo'] }, NA: { name: 'Namibia', zones: ['Africa/Windhoek'] }, NC: { name: 'New Caledonia', zones: ['Pacific/Noumea'] }, NE: { name: 'Niger', zones: ['Africa/Lagos', 'Africa/Niamey'] }, NF: { name: 'Norfolk Island', zones: ['Pacific/Norfolk'] }, NG: { name: 'Nigeria', zones: ['Africa/Lagos'] }, NI: { name: 'Nicaragua', zones: ['America/Managua'] }, NL: { name: 'Netherlands', zones: ['Europe/Amsterdam'] }, NO: { name: 'Norway', zones: ['Europe/Oslo'] }, NP: { name: 'Nepal', zones: ['Asia/Kathmandu'] }, NR: { name: 'Nauru', zones: ['Pacific/Nauru'] }, NU: { name: 'Niue', zones: ['Pacific/Niue'] }, NZ: { name: 'New Zealand', zones: ['Pacific/Auckland', 'Pacific/Chatham'], }, OM: { name: 'Oman', zones: ['Asia/Dubai', 'Asia/Muscat'] }, PA: { name: 'Panama', zones: ['America/Panama'] }, PE: { name: 'Peru', zones: ['America/Lima'] }, PF: { name: 'French Polynesia', zones: ['Pacific/Tahiti', 'Pacific/Marquesas', 'Pacific/Gambier'], }, PG: { name: 'Papua New Guinea', zones: ['Pacific/Port_Moresby', 'Pacific/Bougainville'], }, PH: { name: 'Philippines', zones: ['Asia/Manila'] }, PK: { name: 'Pakistan', zones: ['Asia/Karachi'] }, PL: { name: 'Poland', zones: ['Europe/Warsaw'] }, PM: { name: 'St Pierre & Miquelon', zones: ['America/Miquelon'] }, PN: { name: 'Pitcairn', zones: ['Pacific/Pitcairn'] }, PR: { name: 'Puerto Rico', zones: ['America/Puerto_Rico'] }, PS: { name: 'Palestine', zones: ['Asia/Gaza', 'Asia/Hebron'] }, PT: { name: 'Portugal', zones: ['Europe/Lisbon', 'Atlantic/Madeira', 'Atlantic/Azores'], }, PW: { name: 'Palau', zones: ['Pacific/Palau'] }, PY: { name: 'Paraguay', zones: ['America/Asuncion'] }, QA: { name: 'Qatar', zones: ['Asia/Qatar'] }, RE: { name: 'Réunion', zones: ['Indian/Reunion'] }, RO: { name: 'Romania', zones: ['Europe/Bucharest'] }, RS: { name: 'Serbia', zones: ['Europe/Belgrade'] }, RU: { name: 'Russia', zones: [ 'Europe/Kaliningrad', 'Europe/Moscow', 'Europe/Simferopol', 'Europe/Kirov', 'Europe/Astrakhan', 'Europe/Volgograd', 'Europe/Saratov', 'Europe/Ulyanovsk', 'Europe/Samara', 'Asia/Yekaterinburg', 'Asia/Omsk', 'Asia/Novosibirsk', 'Asia/Barnaul', 'Asia/Tomsk', 'Asia/Novokuznetsk', 'Asia/Krasnoyarsk', 'Asia/Irkutsk', 'Asia/Chita', 'Asia/Yakutsk', 'Asia/Khandyga', 'Asia/Vladivostok', 'Asia/Ust-Nera', 'Asia/Magadan', 'Asia/Sakhalin', 'Asia/Srednekolymsk', 'Asia/Kamchatka', 'Asia/Anadyr', ], }, RW: { name: 'Rwanda', zones: ['Africa/Maputo', 'Africa/Kigali'] }, SA: { name: 'Saudi Arabia', zones: ['Asia/Riyadh'] }, SB: { name: 'Solomon Islands', zones: ['Pacific/Guadalcanal'] }, SC: { name: 'Seychelles', zones: ['Indian/Mahe'] }, SD: { name: 'Sudan', zones: ['Africa/Khartoum'] }, SE: { name: 'Sweden', zones: ['Europe/Stockholm'] }, SG: { name: 'Singapore', zones: ['Asia/Singapore'] }, SH: { name: 'St Helena', zones: ['Africa/Abidjan', 'Atlantic/St_Helena'], }, SI: { name: 'Slovenia', zones: ['Europe/Belgrade', 'Europe/Ljubljana'], }, SJ: { name: 'Svalbard & Jan Mayen', zones: ['Europe/Oslo', 'Arctic/Longyearbyen'], }, SK: { name: 'Slovakia', zones: ['Europe/Prague', 'Europe/Bratislava'], }, SL: { name: 'Sierra Leone', zones: ['Africa/Abidjan', 'Africa/Freetown'], }, SM: { name: 'San Marino', zones: ['Europe/Rome', 'Europe/San_Marino'], }, SN: { name: 'Senegal', zones: ['Africa/Abidjan', 'Africa/Dakar'] }, SO: { name: 'Somalia', zones: ['Africa/Nairobi', 'Africa/Mogadishu'] }, SR: { name: 'Suriname', zones: ['America/Paramaribo'] }, SS: { name: 'South Sudan', zones: ['Africa/Juba'] }, ST: { name: 'Sao Tome & Principe', zones: ['Africa/Sao_Tome'] }, SV: { name: 'El Salvador', zones: ['America/El_Salvador'] }, SX: { name: 'St Maarten (Dutch)', zones: ['America/Curacao', 'America/Lower_Princes'], }, SY: { name: 'Syria', zones: ['Asia/Damascus'] }, SZ: { name: 'Eswatini (Swaziland)', zones: ['Africa/Johannesburg', 'Africa/Mbabane'], }, TC: { name: 'Turks & Caicos Is', zones: ['America/Grand_Turk'] }, TD: { name: 'Chad', zones: ['Africa/Ndjamena'] }, TF: { name: 'French Southern & Antarctic Lands', zones: ['Indian/Reunion', 'Indian/Kerguelen'], }, TG: { name: 'Togo', zones: ['Africa/Abidjan', 'Africa/Lome'] }, TH: { name: 'Thailand', zones: ['Asia/Bangkok'] }, TJ: { name: 'Tajikistan', zones: ['Asia/Dushanbe'] }, TK: { name: 'Tokelau', zones: ['Pacific/Fakaofo'] }, TL: { name: 'East Timor', zones: ['Asia/Dili'] }, TM: { name: 'Turkmenistan', zones: ['Asia/Ashgabat'] }, TN: { name: 'Tunisia', zones: ['Africa/Tunis'] }, TO: { name: 'Tonga', zones: ['Pacific/Tongatapu'] }, TR: { name: 'Turkey', zones: ['Europe/Istanbul'] }, TT: { name: 'Trinidad & Tobago', zones: ['America/Port_of_Spain'] }, TV: { name: 'Tuvalu', zones: ['Pacific/Funafuti'] }, TW: { name: 'Taiwan', zones: ['Asia/Taipei'] }, TZ: { name: 'Tanzania', zones: ['Africa/Nairobi', 'Africa/Dar_es_Salaam'], }, UA: { name: 'Ukraine', zones: [ 'Europe/Simferopol', 'Europe/Kiev', 'Europe/Uzhgorod', 'Europe/Zaporozhye', ], }, UG: { name: 'Uganda', zones: ['Africa/Nairobi', 'Africa/Kampala'] }, UM: { name: 'US minor outlying islands', zones: [ 'Pacific/Pago_Pago', 'Pacific/Wake', 'Pacific/Honolulu', 'Pacific/Midway', ], }, US: { name: 'United States of America (USA)', zones: [ 'America/New_York', 'America/Detroit', 'America/Kentucky/Louisville', 'America/Kentucky/Monticello', 'America/Indiana/Indianapolis', 'America/Indiana/Vincennes', 'America/Indiana/Winamac', 'America/Indiana/Marengo', 'America/Indiana/Petersburg', 'America/Indiana/Vevay', 'America/Chicago', 'America/Indiana/Tell_City', 'America/Indiana/Knox', 'America/Menominee', 'America/North_Dakota/Center', 'America/North_Dakota/New_Salem', 'America/North_Dakota/Beulah', 'America/Denver', 'America/Boise', 'America/Phoenix', 'America/Los_Angeles', 'America/Anchorage', 'America/Juneau', 'America/Sitka', 'America/Metlakatla', 'America/Yakutat', 'America/Nome', 'America/Adak', 'Pacific/Honolulu', ], }, UY: { name: 'Uruguay', zones: ['America/Montevideo'] }, UZ: { name: 'Uzbekistan', zones: ['Asia/Samarkand', 'Asia/Tashkent'] }, VA: { name: 'Vatican City', zones: ['Europe/Rome', 'Europe/Vatican'] }, VC: { name: 'St Vincent', zones: ['America/St_Vincent'], }, VE: { name: 'Venezuela', zones: ['America/Caracas'] }, VG: { name: 'Virgin Islands (UK)', zones: ['America/Tortola'], }, VI: { name: 'Virgin Islands (US)', zones: ['America/St_Thomas'], }, VN: { name: 'Vietnam', zones: ['Asia/Bangkok', 'Asia/Ho_Chi_Minh'] }, VU: { name: 'Vanuatu', zones: ['Pacific/Efate'] }, WF: { name: 'Wallis & Futuna', zones: ['Pacific/Wallis'] }, WS: { name: 'Samoa (western)', zones: ['Pacific/Apia'] }, YE: { name: 'Yemen', zones: ['Asia/Riyadh', 'Asia/Aden'] }, YT: { name: 'Mayotte', zones: ['Africa/Nairobi', 'Indian/Mayotte'] }, ZA: { name: 'South Africa', zones: ['Africa/Johannesburg'] }, ZM: { name: 'Zambia', zones: ['Africa/Maputo', 'Africa/Lusaka'] }, ZW: { name: 'Zimbabwe', zones: ['Africa/Maputo', 'Africa/Harare'] }, }; var NgxTimezonesComponent = /** @class */ (function () { function NgxTimezonesComponent(cdRef) { this.cdRef = cdRef; this.timezoneCtrl = new forms.FormControl(); this.searchControl = new forms.FormControl(); this.timezoneChange = new core.EventEmitter(); this.guess = false; this.showOffset = false; this.placeholder = 'Select timezone'; this.searchPlaceholder = 'Search'; this.noResultsLabel = 'No results'; this.offsetName = 'UTC'; } Object.defineProperty(NgxTimezonesComponent.prototype, "timezone", { set: function (timezone) { this.timezoneCtrl.setValue(timezone); }, enumerable: false, configurable: true }); Object.defineProperty(NgxTimezonesComponent.prototype, "disabled", { set: function (value) { if (value) { this.timezoneCtrl.disable(); } else { this.timezoneCtrl.enable(); } }, enumerable: false, configurable: true }); NgxTimezonesComponent.prototype.ngOnInit = function () { var _this = this; this.initData(); this.timezoneGroupsOptions = this.searchControl.valueChanges.pipe(operators.startWith(''), operators.map(function (query) { return (query ? _this.filter(query) : _this.timezoneGroups.slice()); })); this.timezoneCtrl.valueChanges.subscribe(function (value) { _this.emitTimezone(value); }); if (!this.timezoneCtrl.value && this.guess) { this.guessedTimezone(); this.cdRef.detectChanges(); } }; NgxTimezonesComponent.prototype.guessedTimezone = function () { var zone = moment.tz.guess(); this.timezone = zone; this.emitTimezone(zone); }; NgxTimezonesComponent.prototype.emitTimezone = function (zone) { this.timezoneChange.emit(zone); }; NgxTimezonesComponent.prototype.initData = function () { var _this = this; this.timezoneGroups = Object.keys(countryZones).map(function (iso) { var val = countryZones[iso]; var hasMultiple = val.zones.length > 1; var zones = val.zones.map(function (x) { return hasMultiple ? { zone: x, name: "" + _this.formatTimezoneString(x), offset: _this.offsetOfTimezone(x), } : { zone: x, name: val.name, offset: _this.offsetOfTimezone(x), }; }); return { iso: iso, country: val.name, zones: zones }; }); }; NgxTimezonesComponent.prototype.filter = function (query) { var e_1, _a; var result = []; try { for (var _b = __values(this.timezoneGroups), _c = _b.next(); !_c.done; _c = _b.next()) { var z = _c.value; if (z.country && z.country.toLowerCase().includes(query.toLowerCase())) { result.push(z); } else { var results = z.zones.filter(function (x) { return x.name.toLowerCase().includes(query.toLowerCase()); }); if (results.length > 0) { z.zones = results; z.showGroup = z.zones.length > 1; result.push(z); } } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } } return result; }; NgxTimezonesComponent.prototype.formatTimezoneString = function (zone) { var arr = zone.split('/'); return arr[arr.length - 1].split('_').join(' '); }; NgxTimezonesComponent.prototype.offsetOfTimezone = function (zone) { var offset = moment.tz(zone).utcOffset(); var neg = offset < 0; if (neg) { offset = -1 * offset; } var hours = Math.floor(offset / 60); var minutes = (offset / 60 - hours) * 60; return "" + (neg ? '-' : '+') + this.rjust(hours.toString(), 2) + ":" + this.rjust(minutes.toString(), 2); }; NgxTimezonesComponent.prototype.formatOffset = function (offset) { return "(" + this.offsetName + offset + ")"; }; NgxTimezonesComponent.prototype.rjust = function (value, width, padding) { if (padding === void 0) { padding = '0'; } padding = padding || ' '; padding = padding.substr(0, 1); if (value.length < width) { return padding.repeat(width - value.length) + value; } else { return value; } }; return NgxTimezonesComponent; }()); NgxTimezonesComponent.decorators = [ { type: core.Component, args: [{ selector: 'ngx-timezones', template: " <mat-form-field style=\"width: 100%\"\n ><mat-select [formControl]=\"timezoneCtrl\" [placeholder]=\"placeholder\">\n <mat-option>\n <ngx-mat-select-search\n [formControl]=\"searchControl\"\n [placeholderLabel]=\"searchPlaceholder\"\n [noEntriesFoundLabel]=\"noResultsLabel\"\n ></ngx-mat-select-search>\n </mat-option>\n <ng-template let-option ngFor [ngForOf]=\"timezoneGroupsOptions | async\">\n <mat-optgroup\n *ngIf=\"option.showGroup || option.zones.length > 1; else singleOption\"\n [label]=\"option.country + ' (' + option.zones.length + ')'\"\n >\n <mat-option *ngFor=\"let zone of option.zones\" [value]=\"zone.zone\">\n {{ zone.name }}\n <span>{{ showOffset ? formatOffset(zone.offset) : '' }}</span>\n </mat-option>\n </mat-optgroup>\n <ng-template #singleOption>\n <mat-option [value]=\"option.zones[0].zone\">\n {{ option.zones[0].name }}\n <span>{{\n showOffset ? formatOffset(option.zones[0].offset) : ''\n }}</span>\n </mat-option>\n </ng-template>\n </ng-template>\n </mat-select>\n </mat-form-field>" },] } ]; NgxTimezonesComponent.ctorParameters = function () { return [ { type: core.ChangeDetectorRef } ]; }; NgxTimezonesComponent.propDecorators = { timezoneChange: [{ type: core.Output }], timezone: [{ type: core.Input }], disabled: [{ type: core.Input }], guess: [{ type: core.Input }], showOffset: [{ type: core.Input }], placeholder: [{ type: core.Input }], searchPlaceholder: [{ type: core.Input }], noResultsLabel: [{ type: core.Input }], offsetName: [{ type: core.Input }] }; var NgxTimezonesModule = /** @class */ (function () { function NgxTimezonesModule() { } return NgxTimezonesModule; }()); NgxTimezonesModule.decorators = [ { type: core.NgModule, args: [{ declarations: [NgxTimezonesComponent], imports: [ forms.ReactiveFormsModule, animations.BrowserAnimationsModule, select.MatSelectModule, forms.FormsModule, formField.MatFormFieldModule, ngxMatSelectSearch.NgxMatSelectSearchModule, ], exports: [NgxTimezonesComponent], },] } ]; /* * Public API Surface of ngx-timezones */ /** * Generated bundle index. Do not edit. */ exports.NgxTimezonesComponent = NgxTimezonesComponent; exports.NgxTimezonesModule = NgxTimezonesModule; Object.defineProperty(exports, '__esModule', { value: true }); }))); //# sourceMappingURL=ngx-timezones.umd.js.map