add proper date formats
This commit is contained in:
parent
6649de111a
commit
a2f2d59fa4
3 changed files with 16 additions and 6 deletions
|
@ -4,10 +4,12 @@ export default class JoinDateCommand extends Command {
|
|||
|
||||
#chat
|
||||
#stmt
|
||||
#dateFormat
|
||||
|
||||
constructor(chat, db) {
|
||||
constructor(chat, db, dateFormat) {
|
||||
super("joindate")
|
||||
this.#chat = chat
|
||||
this.#dateFormat = dateFormat
|
||||
|
||||
this.#stmt = db.prepare(`
|
||||
SELECT p.first_online
|
||||
|
@ -40,6 +42,6 @@ export default class JoinDateCommand extends Command {
|
|||
}
|
||||
|
||||
const firstOnline = new Date(data["first_online"])
|
||||
this.#chat.chat(`I first saw ${target} at ${firstOnline.toDateString()}`)
|
||||
this.#chat.chat(`I first saw ${target} at ${this.#dateFormat.format(firstOnline)}`)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,12 @@ export default class SeenCommand extends Command {
|
|||
|
||||
#chat
|
||||
#stmt
|
||||
#dateFormat
|
||||
|
||||
constructor(chat, db) {
|
||||
constructor(chat, db, dateFormat) {
|
||||
super("seen")
|
||||
this.#chat = chat
|
||||
this.#dateFormat = dateFormat
|
||||
|
||||
this.#stmt = db.prepare(`
|
||||
SELECT p.last_online
|
||||
|
@ -40,6 +42,6 @@ export default class SeenCommand extends Command {
|
|||
}
|
||||
|
||||
const firstOnline = new Date(data["last_online"])
|
||||
this.#chat.chat(`I last saw ${target} at ${firstOnline.toDateString()}`)
|
||||
this.#chat.chat(`I last saw ${target} at ${this.#dateFormat.format(firstOnline)}`)
|
||||
}
|
||||
}
|
||||
|
|
10
src/main.js
10
src/main.js
|
@ -31,6 +31,12 @@ migrateDB(db)
|
|||
|
||||
const reconnectDelay = 10_000
|
||||
|
||||
const dateFormat = new Intl.DateTimeFormat("en-US", {
|
||||
dateStyle: "medium",
|
||||
timeStyle: "medium",
|
||||
timeZone: "UTC",
|
||||
})
|
||||
|
||||
function newClient() {
|
||||
console.log("Client connecting")
|
||||
|
||||
|
@ -122,10 +128,10 @@ function newClient() {
|
|||
const commands = new Commands(chat, "!")
|
||||
commands.register(new BestPingCommand(chat, players))
|
||||
commands.register(new HelpCommand(chat, commands))
|
||||
commands.register(new JoinDateCommand(chat, db))
|
||||
commands.register(new JoinDateCommand(chat, db, dateFormat))
|
||||
commands.register(new PingCommand(chat, players))
|
||||
commands.register(new PlaytimeCommand(chat, db))
|
||||
commands.register(new SeenCommand(chat, db))
|
||||
commands.register(new SeenCommand(chat, db, dateFormat))
|
||||
commands.register(new TPSCommand(chat, tps))
|
||||
commands.register(new WorstPingCommand(chat, players))
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue