Show local time zone of visitor in more places

This commit is contained in:
Raphael Michel
2021-01-24 22:43:01 +01:00
parent a3ff3cda12
commit c2ba312bad
7 changed files with 28 additions and 19 deletions

View File

@@ -424,7 +424,7 @@ $(function () {
}
var local_tz = moment.tz.guess()
$("span[data-timezone]").each(function() {
$("span[data-timezone], small[data-timezone]").each(function() {
var t = moment.tz($(this).attr("data-time"), $(this).attr("data-timezone"))
var tz = moment.tz.zone($(this).attr("data-timezone"))
@@ -432,17 +432,22 @@ $(function () {
'title': gettext("Time zone:") + " " + tz.abbr(t)
});
if (t.tz(tz.name).format() !== t.tz(local_tz).format()) {
var $add = $("<span>").addClass("text-muted")
var $add = $("<span>")
$add.append($("<span>").addClass("fa fa-globe"))
$add.append(" " + gettext("Your local time:") + " ")
if (t.tz(tz.name).format("YYYY-MM-DD") != t.tz(local_tz).format("YYYY-MM-DD")) {
$add.append(t.tz(local_tz).format($("body").attr("data-datetimeformat")))
if ($(this).is("[data-time-short]")) {
$add.append($("<em>").text(" " + t.tz(local_tz).format($("body").attr("data-timeformat"))))
} else {
$add.append(t.tz(local_tz).format($("body").attr("data-timeformat")))
$add.addClass("text-muted")
$add.append(" " + gettext("Your local time:") + " ")
if (t.tz(tz.name).format("YYYY-MM-DD") != t.tz(local_tz).format("YYYY-MM-DD")) {
$add.append(t.tz(local_tz).format($("body").attr("data-datetimeformat")))
} else {
$add.append(t.tz(local_tz).format($("body").attr("data-timeformat")))
}
}
$add.insertAfter($(this));
$add.tooltip({
'title': gettext("Time zone:") + " " + moment.tz.zone(local_tz).abbr(t)
'title': gettext("Time zone:") + " " + moment.tz.zone(local_tz).abbr(t),
});
}
});