UNPKG

2.08 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../lib/formatTimeZone.js"],"names":["format","alternativeName","mainCities","rawOffsetInMinutes","currentTimeOffsetInMinutes","useCurrentOffset","offsetInHours","getOffsetString","padStart","join","offsetInMinutes","absOffsetInMinutes","Math","abs","hours","minutes","floor","map","v","toString","durationInHoursMinutes"],"mappings":";;;;;;;AAAe,SAASA,MAAT,CACb;AACEC,EAAAA,eADF;AAEEC,EAAAA,UAFF;AAGEC,EAAAA,kBAHF;AAIEC,EAAAA;AAJF,CADa,EAOb;AAAEC,EAAAA,gBAAgB,GAAG;AAArB,IAA+B,EAPlB,EAQb;AACA,QAAMC,aAAa,GAAGD,gBAAgB,GAClCE,eAAe,CAACH,0BAAD,CADmB,GAElCG,eAAe,CAACJ,kBAAD,CAFnB;AAIA,SAAQ,GAAEG,aAAa,CAACE,QAAd,CACR,CADQ,EAER,GAFQ,CAGR,IAAGP,eAAgB,MAAKC,UAAU,CAACO,IAAX,CAAgB,IAAhB,CAAsB,EAHhD;AAID;;AAED,SAASF,eAAT,CAAyBG,eAAzB,EAA0C;AACxC,QAAMC,kBAAkB,GAAGC,IAAI,CAACC,GAAL,CAASH,eAAT,CAA3B;AACA,QAAM,CAACI,KAAD,EAAQC,OAAR,IAAmB,CACvBH,IAAI,CAACI,KAAL,CAAWL,kBAAkB,GAAG,EAAhC,CADuB,EAEvBA,kBAAkB,GAAG,EAFE,EAGvBM,GAHuB,CAGlBC,CAAD,IAAO;AACX,WAAOA,CAAC,CAACC,QAAF,GAAaX,QAAb,CAAsB,CAAtB,EAAyB,GAAzB,CAAP;AACD,GALwB,CAAzB;AAMA,QAAMY,sBAAsB,GAAI,GAAEN,KAAM,IAAGC,OAAQ,EAAnD;AAEA,SAAQ,GAAEL,eAAe,IAAI,CAAnB,GAAuB,GAAvB,GAA6B,GAAI,GAAEU,sBAAuB,EAApE;AACD","sourcesContent":["export default function format(\n {\n alternativeName,\n mainCities,\n rawOffsetInMinutes,\n currentTimeOffsetInMinutes,\n },\n { useCurrentOffset = false } = {},\n) {\n const offsetInHours = useCurrentOffset\n ? getOffsetString(currentTimeOffsetInMinutes)\n : getOffsetString(rawOffsetInMinutes);\n\n return `${offsetInHours.padStart(\n 6,\n \"+\",\n )} ${alternativeName} - ${mainCities.join(\", \")}`;\n}\n\nfunction getOffsetString(offsetInMinutes) {\n const absOffsetInMinutes = Math.abs(offsetInMinutes);\n const [hours, minutes] = [\n Math.floor(absOffsetInMinutes / 60),\n absOffsetInMinutes % 60,\n ].map((v) => {\n return v.toString().padStart(2, \"0\");\n });\n const durationInHoursMinutes = `${hours}:${minutes}`;\n\n return `${offsetInMinutes >= 0 ? \"+\" : \"-\"}${durationInHoursMinutes}`;\n}\n"],"file":"formatTimeZone.js"}
\No newline at end of file