Websites/app/javascript/controllers/e621_ws/status_controller.ts
2024-05-02 22:04:43 -05:00

20 lines
511 B
TypeScript

import { Controller } from "@hotwired/stimulus"
// Connects to data-controller="e621-ws--status"
export default class extends Controller {
static override targets = ["rawTime", "time"];
declare rawTimeTarget: HTMLElement;
declare timeTarget: HTMLElement;
override connect() {
const fmt = new Intl.DateTimeFormat(undefined, {
dateStyle: "medium",
timeStyle: "long",
hour12: false
});
this.timeTarget.innerHTML = fmt.format(new Date(this.rawTimeTarget.innerText));
}
}