Use timezone preference
This commit is contained in:
parent
bf5798c4e5
commit
c62f9c0ddc
2 changed files with 9 additions and 1 deletions
|
@ -85,6 +85,11 @@ function padLeft(input, width, padding=" ") {
|
|||
return text;
|
||||
}
|
||||
|
||||
function toTimeZone(date, timezoneString) {
|
||||
// https://stackoverflow.com/questions/10087819/convert-date-to-another-timezone-in-javascript
|
||||
return new Date(date.toLocaleString("en-US", {timeZone: timezoneString}));
|
||||
}
|
||||
|
||||
function formatDdddMmYy(date) {
|
||||
return `${date.getFullYear()}-${padLeft(date.getMonth() + 1, 2, "0")}-${padLeft(date.getDate(), 2, "0")}`;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,10 @@ async function createMessageElement(client, post, lastTime, lastAuthor) {
|
|||
messageDiv.className = "message";
|
||||
messageDiv.innerText = transformMessageText(post.message);
|
||||
|
||||
const createAt = new Date(post.create_at);
|
||||
let createAt = new Date(post.create_at);
|
||||
if (client.me.timezone.useAutomaticTimezone !== "true") {
|
||||
createAt = toTimeZone(createAt, client.me.timezone.manualTimezone);
|
||||
}
|
||||
const createAtDiv = document.createElement("time");
|
||||
createAtDiv.className = "create_at";
|
||||
const sim = dateSimilarity(lastTime, createAt);
|
||||
|
|
Loading…
Reference in a new issue