Websites/app/javascript/controllers/e621_ws/status_controller.ts

20 lines
511 B
TypeScript
Raw Normal View History

2024-05-03 03:04:43 +00:00
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));
}
}