1
0
mirror of https://github.com/hrfee/jfa-go.git synced 2024-06-26 03:17:47 +02:00

(hopefully) get proper locale from browser

This commit is contained in:
Harvey Tindall 2021-04-07 14:05:17 +01:00
parent 3e73d16cce
commit 7196361cf6
Signed by: hrfee
GPG Key ID: BBC65952848FB1A2
3 changed files with 7 additions and 6 deletions

View File

@ -83,7 +83,7 @@ class user implements User {
set last_active(unix: number) {
this._lastActiveUnix = unix;
if (unix == 0) {
this._lastActive.textContent == "";
this._lastActive.textContent == "n/a";
} else {
this._lastActive.textContent = toDateString(new Date(unix*1000));
}

View File

@ -7,7 +7,8 @@ export function createEl(html: string): HTMLElement {
}
export function toDateString(date: Date): string {
return date.toLocaleDateString() + " " + date.toLocaleString([], {
const locale = (window as any).navigator.userLanguage || window.navigator.language;
return date.toLocaleDateString(locale) + " " + date.toLocaleString(locale, {
hour: "2-digit",
minute: "2-digit"
})

View File

@ -8,7 +8,7 @@ interface updateDTO {
export class Updater implements updater {
private _update: Update;
private _date: Date;
private _date: number;
updateAvailable = false;
checkForUpdates = (run?: (req: XMLHttpRequest) => void) => _get("/config/update", null, (req: XMLHttpRequest) => {
@ -26,10 +26,10 @@ export class Updater implements updater {
}
}
});
get date(): number { return Math.floor(this._date.getTime() / 1000); }
get date(): number { return this._date; }
set date(unix: number) {
this._date = new Date(unix * 1000);
document.getElementById("update-date").textContent = toDateString(this._date);
this._date = unix;
document.getElementById("update-date").textContent = toDateString(new Date(this._date * 1000));
}
get description(): string { return this._update.description; }