UNPKG

894 BJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = format;
7
8function format({
9 alternativeName,
10 mainCities,
11 rawOffsetInMinutes,
12 currentTimeOffsetInMinutes
13}, {
14 useCurrentOffset = false
15} = {}) {
16 const offsetInHours = useCurrentOffset ? getOffsetString(currentTimeOffsetInMinutes) : getOffsetString(rawOffsetInMinutes);
17 return `${offsetInHours.padStart(6, "+")} ${alternativeName} - ${mainCities.join(", ")}`;
18}
19
20function getOffsetString(offsetInMinutes) {
21 const absOffsetInMinutes = Math.abs(offsetInMinutes);
22 const [hours, minutes] = [Math.floor(absOffsetInMinutes / 60), absOffsetInMinutes % 60].map(v => {
23 return v.toString().padStart(2, "0");
24 });
25 const durationInHoursMinutes = `${hours}:${minutes}`;
26 return `${offsetInMinutes >= 0 ? "+" : "-"}${durationInHoursMinutes}`;
27}
28//# sourceMappingURL=formatTimeZone.js.map
\No newline at end of file