Show local time if browser timezone is different

This commit is contained in:
Raphael Michel
2020-07-09 14:51:16 +02:00
parent fddf134755
commit 3affaa8c85
4 changed files with 1591 additions and 12 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -369,6 +369,30 @@ $(function () {
});
}
var local_tz = moment.tz.guess()
$("span[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"))
$(this).tooltip({
'title': gettext("Time zone:") + " " + tz.abbr(t)
});
if (t.tz(tz.name).format() !== t.tz(local_tz).format()) {
var $add = $("<span>").addClass("text-muted")
$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")))
} 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)
});
}
});
// Lightbox
lightbox.init();
});