FIX: removes country from timezone indicator (#6677)
This commit is contained in:
parent
ac556298ca
commit
d461794fbf
|
@ -84,6 +84,11 @@
|
||||||
.replace("Etc/", "")
|
.replace("Etc/", "")
|
||||||
.split("/");
|
.split("/");
|
||||||
|
|
||||||
|
const _zoneWithoutPrefix = timezone => {
|
||||||
|
const parts = _formatTimezone(timezone);
|
||||||
|
return parts[1] || parts[0];
|
||||||
|
};
|
||||||
|
|
||||||
const _applyZoneToDateTime = (dateTime, timezone) => {
|
const _applyZoneToDateTime = (dateTime, timezone) => {
|
||||||
return moment.tz(dateTime, timezone).utc();
|
return moment.tz(dateTime, timezone).utc();
|
||||||
};
|
};
|
||||||
|
@ -132,9 +137,7 @@
|
||||||
} else {
|
} else {
|
||||||
dateTime = dateTime.format(options.format);
|
dateTime = dateTime.format(options.format);
|
||||||
dateTime = dateTime.replace("TZ", "");
|
dateTime = dateTime.replace("TZ", "");
|
||||||
dateTime = `${dateTime} (${_formatTimezone(displayedTimezone).join(
|
dateTime = `${dateTime} (${_zoneWithoutPrefix(displayedTimezone)})`;
|
||||||
": "
|
|
||||||
)})`;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (options.time) {
|
if (options.time) {
|
||||||
|
@ -142,9 +145,7 @@
|
||||||
|
|
||||||
if (options.displayedTimezone && !sameTimezone) {
|
if (options.displayedTimezone && !sameTimezone) {
|
||||||
dateTime = dateTime.replace("TZ", "");
|
dateTime = dateTime.replace("TZ", "");
|
||||||
dateTime = `${dateTime} (${_formatTimezone(displayedTimezone).join(
|
dateTime = `${dateTime} (${_zoneWithoutPrefix(displayedTimezone)})`;
|
||||||
": "
|
|
||||||
)})`;
|
|
||||||
} else {
|
} else {
|
||||||
dateTime = dateTime.replace(
|
dateTime = dateTime.replace(
|
||||||
"TZ",
|
"TZ",
|
||||||
|
@ -156,13 +157,11 @@
|
||||||
|
|
||||||
if (!sameTimezone) {
|
if (!sameTimezone) {
|
||||||
dateTime = dateTime.replace("TZ", "");
|
dateTime = dateTime.replace("TZ", "");
|
||||||
dateTime = `${dateTime} (${_formatTimezone(displayedTimezone).join(
|
dateTime = `${dateTime} (${_zoneWithoutPrefix(displayedTimezone)})`;
|
||||||
": "
|
|
||||||
)})`;
|
|
||||||
} else {
|
} else {
|
||||||
dateTime = dateTime.replace(
|
dateTime = dateTime.replace(
|
||||||
"TZ",
|
"TZ",
|
||||||
_formatTimezone(displayedTimezone).join(": ")
|
_zoneWithoutPrefix(displayedTimezone)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -223,14 +222,12 @@
|
||||||
const _generateTextPreview = previews => {
|
const _generateTextPreview = previews => {
|
||||||
return previews
|
return previews
|
||||||
.map(preview => {
|
.map(preview => {
|
||||||
const timezoneParts = _formatTimezone(preview.timezone);
|
const formatedZone = _zoneWithoutPrefix(preview.timezone);
|
||||||
|
|
||||||
if (preview.dateTime.match(/TZ/)) {
|
if (preview.dateTime.match(/TZ/)) {
|
||||||
return preview.dateTime.replace(/TZ/, timezoneParts.join(": "));
|
return preview.dateTime.replace(/TZ/, formatedZone);
|
||||||
} else {
|
} else {
|
||||||
let output = timezoneParts[0];
|
return `${formatedZone} ${preview.dateTime}`;
|
||||||
if (timezoneParts[1]) output += ` (${timezoneParts[1]})`;
|
|
||||||
return (output += ` ${preview.dateTime}`);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.join(", ");
|
.join(", ");
|
||||||
|
@ -251,9 +248,7 @@
|
||||||
|
|
||||||
if (preview.current) $template.addClass("current");
|
if (preview.current) $template.addClass("current");
|
||||||
|
|
||||||
$template
|
$template.find(".timezone").text(_zoneWithoutPrefix(preview.timezone));
|
||||||
.find(".timezone")
|
|
||||||
.text(_formatTimezone(preview.timezone).join(": "));
|
|
||||||
$template.find(".date-time").text(preview.dateTime);
|
$template.find(".date-time").text(preview.dateTime);
|
||||||
$htmlTooltip.append($template);
|
$htmlTooltip.append($template);
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,7 +16,7 @@ acceptance("Local Dates", {
|
||||||
|
|
||||||
const DEFAULT_DATE = "2018-06-20";
|
const DEFAULT_DATE = "2018-06-20";
|
||||||
const DEFAULT_ZONE = "Europe/Paris";
|
const DEFAULT_ZONE = "Europe/Paris";
|
||||||
const DEFAULT_ZONE_FORMATED = DEFAULT_ZONE.split("/").join(": ");
|
const DEFAULT_ZONE_FORMATED = DEFAULT_ZONE.split("/")[1];
|
||||||
|
|
||||||
function advance(count, unit = "days") {
|
function advance(count, unit = "days") {
|
||||||
return moment(DEFAULT_DATE)
|
return moment(DEFAULT_DATE)
|
||||||
|
@ -237,7 +237,7 @@ test("displayedTimezone", assert => {
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
transformed.text().trim(),
|
transformed.text().trim(),
|
||||||
"June 23, 2018 9:00 AM (America: Chicago)",
|
"June 23, 2018 9:00 AM (Chicago)",
|
||||||
"it displays timezone when different from watching user"
|
"it displays timezone when different from watching user"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ test("displayedTimezone", assert => {
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
transformed.text().trim(),
|
transformed.text().trim(),
|
||||||
"June 20, 2018 (America: Chicago)",
|
"June 20, 2018 (Chicago)",
|
||||||
"it uses timezone when displayedTimezone is not set"
|
"it uses timezone when displayedTimezone is not set"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ test("displayedTimezone", assert => {
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
transformed.text().trim(),
|
transformed.text().trim(),
|
||||||
"June 20, 2018 (Pacific: Auckland)",
|
"June 20, 2018 (Auckland)",
|
||||||
"it uses displayedTimezone over timezone"
|
"it uses displayedTimezone over timezone"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue