diff --git a/app/javascript/controllers/local_time_controller.js b/app/javascript/controllers/local_time_controller.js index 445545a76..86d5e58e6 100644 --- a/app/javascript/controllers/local_time_controller.js +++ b/app/javascript/controllers/local_time_controller.js @@ -1,11 +1,12 @@ import { Controller } from "@hotwired/stimulus" export default class extends Controller { - static targets = ["time", "date", "datetime", "ago"] + static targets = ["time", "date", "datetime", "shortdate", "ago"] initialize() { this.timeFormatter = new Intl.DateTimeFormat(undefined, { timeStyle: "short" }) this.dateFormatter = new Intl.DateTimeFormat(undefined, { dateStyle: "long" }) + this.shortDateFormatter = new Intl.DateTimeFormat(undefined, { month: "short", day: "numeric" }) this.dateTimeFormatter = new Intl.DateTimeFormat(undefined, { timeStyle: "short", dateStyle: "short" }) this.agoFormatter = new AgoFormatter() } @@ -22,6 +23,10 @@ export default class extends Controller { this.#formatTime(this.dateTimeFormatter, target) } + shortdateTargetConnected(target) { + this.#formatTime(this.shortDateFormatter, target) + } + agoTargetConnected(target) { this.#formatTime(this.agoFormatter, target) } diff --git a/app/views/comments/_body.html.erb b/app/views/comments/_body.html.erb index d2a060192..63581c7aa 100644 --- a/app/views/comments/_body.html.erb +++ b/app/views/comments/_body.html.erb @@ -3,9 +3,7 @@