1 | {"version":3,"sources":["../lib/getTimeZones.js"],"names":["getTimeZones","opts","includeUtc","rawTimeZones","reduce","acc","timeZone","timeZoneName","name","currentOffset","timeZoneWithCurrentTimeData","currentTimeOffsetInMinutes","push","currentTimeFormat","useCurrentOffset","utcTimezone","sort","a","b","compareNumbers","compareStrings","alternativeName","mainCities","x","y","localeCompare","abbreviation","group","countryName","continentCode","continentName","rawOffsetInMinutes","rawFormat"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;;;AAEe,SAASA,YAAT,CAAsBC,IAAtB,EAA4B;AACzC,QAAMC,UAAU,GAAG,CAAC,CAACD,IAAF,IAAUA,IAAI,CAACC,UAAlC;AACA,SAAOC,sBACJC,MADI,CAEH,UAAUC,GAAV,EAAeC,QAAf,EAAyB;AACvB,UAAMC,YAAY,GAAGD,QAAQ,CAACE,IAA9B;AACA,UAAMC,aAAa,GAAG,6BAAcF,YAAd,CAAtB,CAFuB,CAIvB;AACA;AACA;AACA;;AACA,QAAIE,aAAa,KAAK,KAAtB,EAA6B;AAC3B,aAAOJ,GAAP;AACD;;AAED,UAAMK,2BAA2B,GAAG,EAClC,GAAGJ,QAD+B;AAElCK,MAAAA,0BAA0B,EAAEF;AAFM,KAApC;AAKAJ,IAAAA,GAAG,CAACO,IAAJ,CAAS,EACP,GAAGF,2BADI;AAEPG,MAAAA,iBAAiB,EAAE,6BAAeH,2BAAf,EAA4C;AAC7DI,QAAAA,gBAAgB,EAAE;AAD2C,OAA5C;AAFZ,KAAT;AAOA,WAAOT,GAAP;AACD,GA3BE,EA4BHH,UAAU,GAAG,CAACa,WAAD,CAAH,GAAmB,EA5B1B,EA8BJC,IA9BI,CA8BC,CAACC,CAAD,EAAIC,CAAJ,KAAU;AACd,WACEC,cAAc,CAACF,CAAD,EAAIC,CAAJ,CAAd,IACAE,cAAc,CAACH,CAAC,CAACI,eAAH,EAAoBH,CAAC,CAACG,eAAtB,CADd,IAEAD,cAAc,CAACH,CAAC,CAACK,UAAF,CAAa,CAAb,CAAD,EAAkBJ,CAAC,CAACI,UAAF,CAAa,CAAb,CAAlB,CAHhB;AAKD,GApCI,CAAP;AAqCD;;AAED,SAASH,cAAT,CAAwBI,CAAxB,EAA2BC,CAA3B,EAA8B;AAC5B,SAAOD,CAAC,CAACZ,0BAAF,GAA+Ba,CAAC,CAACb,0BAAxC;AACD;;AAED,SAASS,cAAT,CAAwBG,CAAxB,EAA2BC,CAA3B,EAA8B;AAC5B,MAAI,OAAOD,CAAP,KAAa,QAAb,IAAyB,OAAOC,CAAP,KAAa,QAA1C,EAAoD;AAClD,WAAOD,CAAC,CAACE,aAAF,CAAgBD,CAAhB,CAAP;AACD;;AACD,SAAO,CAAP;AACD;;AAED,MAAMT,WAAW,GAAG;AAClBP,EAAAA,IAAI,EAAE,SADY;AAElBa,EAAAA,eAAe,EAAE,kCAFC;AAGlBK,EAAAA,YAAY,EAAE,KAHI;AAIlBC,EAAAA,KAAK,EAAE,CAAC,SAAD,EAAY,SAAZ,EAAuB,KAAvB,EAA8B,KAA9B,EAAqC,WAArC,EAAkD,MAAlD,CAJW;AAKlBC,EAAAA,WAAW,EAAE,EALK;AAMlBC,EAAAA,aAAa,EAAE,EANG;AAOlBC,EAAAA,aAAa,EAAE,EAPG;AAQlBR,EAAAA,UAAU,EAAE,CAAC,EAAD,CARM;AASlBS,EAAAA,kBAAkB,EAAE,CATF;AAUlBC,EAAAA,SAAS,EAAE,yCAVO;AAWlBrB,EAAAA,0BAA0B,EAAE,CAXV;AAYlBE,EAAAA,iBAAiB,EAAE;AAZD,CAApB","sourcesContent":["import rawTimeZones from \"../raw-time-zones.json\";\n\nimport formatTimeZone from \"./formatTimeZone.js\";\nimport { getZoneOffset } from \"./utils/timeZone.js\";\n\nexport default function getTimeZones(opts) {\n const includeUtc = !!opts && opts.includeUtc;\n return rawTimeZones\n .reduce(\n function (acc, timeZone) {\n const timeZoneName = timeZone.name;\n const currentOffset = getZoneOffset(timeZoneName);\n\n // We build on the latest Node.js version, Node.js embed IANA databases\n // it might happen that the environment that will execute getTimeZones() will not know about some\n // timezones. So we ignore the timezone at runtim\n // See https://github.com/vvo/tzdb/issues/43\n if (currentOffset === false) {\n return acc;\n }\n\n const timeZoneWithCurrentTimeData = {\n ...timeZone,\n currentTimeOffsetInMinutes: currentOffset,\n };\n\n acc.push({\n ...timeZoneWithCurrentTimeData,\n currentTimeFormat: formatTimeZone(timeZoneWithCurrentTimeData, {\n useCurrentOffset: true,\n }),\n });\n\n return acc;\n },\n includeUtc ? [utcTimezone] : [],\n )\n .sort((a, b) => {\n return (\n compareNumbers(a, b) ||\n compareStrings(a.alternativeName, b.alternativeName) ||\n compareStrings(a.mainCities[0], b.mainCities[0])\n );\n });\n}\n\nfunction compareNumbers(x, y) {\n return x.currentTimeOffsetInMinutes - y.currentTimeOffsetInMinutes;\n}\n\nfunction compareStrings(x, y) {\n if (typeof x === \"string\" && typeof y === \"string\") {\n return x.localeCompare(y);\n }\n return 0;\n}\n\nconst utcTimezone = {\n name: \"Etc/UTC\",\n alternativeName: \"Coordinated Universal Time (UTC)\",\n abbreviation: \"UTC\",\n group: [\"Etc/UTC\", \"Etc/UCT\", \"UCT\", \"UTC\", \"Universal\", \"Zulu\"],\n countryName: \"\",\n continentCode: \"\",\n continentName: \"\",\n mainCities: [\"\"],\n rawOffsetInMinutes: 0,\n rawFormat: \"+00:00 Coordinated Universal Time (UTC)\",\n currentTimeOffsetInMinutes: 0,\n currentTimeFormat: \"+00:00 Coordinated Universal Time (UTC)\",\n};\n"],"file":"getTimeZones.js"} |