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