20 lines
511 B
TypeScript
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));
|
||
|
}
|
||
|
}
|