make dates rendered server-side & consistently in YYYY-MM-DD format
client-side time zone adjustment still persists---the server renders them out in UTC, but the client will adjust the date to its timezone during loading. this shouldn't cause any layout shifting because we use `font-variant-numeric: tabular-nums` (though Recursive seems to use tabular numbers either way.)
This commit is contained in:
parent
81373b1076
commit
1953b649cf
3 changed files with 20 additions and 5 deletions
|
@ -318,9 +318,10 @@ th-bb {
|
|||
}
|
||||
|
||||
/* Style branch dates to be smaller and less noticable. */
|
||||
th-bb .branch-date {
|
||||
th-bd {
|
||||
opacity: 50%;
|
||||
font-size: 0.8em;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* Hide branch dates on very small displays. No clue how to fix this just yet. */
|
||||
|
|
|
@ -18,6 +18,10 @@ function branchIsOpen(branchID) {
|
|||
return branchState[branchID];
|
||||
}
|
||||
|
||||
function dateToString(date) {
|
||||
return new Date(date - date.getTimezoneOffset() * 60000).toISOString().substring(0, 10);
|
||||
}
|
||||
|
||||
export class Branch {
|
||||
static branchesByNamedID = new Map();
|
||||
static onAdded = [];
|
||||
|
@ -70,11 +74,10 @@ export class Branch {
|
|||
}
|
||||
|
||||
if (ulid.isCanonicalUlid(this.namedID)) {
|
||||
// Adjust dates to fit the user's time zone.
|
||||
let timestamp = ulid.getTimestamp(this.namedID);
|
||||
let date = document.createElement("span");
|
||||
date.classList.add("branch-date");
|
||||
date.innerText = timestamp.toLocaleDateString();
|
||||
this.buttonBar.insertBefore(date, this.buttonBar.firstChild);
|
||||
let branchDate = this.buttonBar.getElementsByTagName("th-bd")[0];
|
||||
branchDate.textContent = dateToString(timestamp);
|
||||
}
|
||||
|
||||
for (let callback of Branch.onAdded) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue